User Tools

Site Tools


tutorial:extendedscreenhandler

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
tutorial:extendedscreenhandler [2020/08/15 18:55] technici4ntutorial:extendedscreenhandler [2022/05/27 15:59] – external edit 127.0.0.1
Line 41: Line 41:
     @Override     @Override
     public Text getDisplayName() {     public Text getDisplayName() {
 +        // versions 1.18 and below
         return new TranslatableText(getCachedState().getBlock().getTranslationKey());         return new TranslatableText(getCachedState().getBlock().getTranslationKey());
 +        
 +        // versions 1.19 and later
 +        return Text.translatable(getCachedState().getBlock().getTranslationKey());
     }     }
  
Line 127: Line 131:
         if (handler instanceof BoxScreenHandler) {         if (handler instanceof BoxScreenHandler) {
             BlockPos pos = ((BoxScreenHandler) handler).getPos();             BlockPos pos = ((BoxScreenHandler) handler).getPos();
-            return pos != null ? Optional.of(new LiteralText("(" + pos.toShortString() + ")")) : Optional.empty();+            // for versions 1.18.2 and below, use `new LiteralText` 
 +            return pos != null ? Optional.of(Text.literal("(" + pos.toShortString() + ")")) : Optional.empty();
         } else {         } else {
             return Optional.empty();             return Optional.empty();
Line 173: Line 178:
  
 You might be wondering: //Can I transfer this data again even after the Screen was opened?// You might be wondering: //Can I transfer this data again even after the Screen was opened?//
-This is possible by sending custom Packets (see: [[tutorial:networking|Networking Tutorial]]) after the Screen has been opened. +This is possible by sending custom Packets (see: [[tutorial:networking|Networking Tutorial]]) after the Screen has been opened. \\
 You might also want to have a look at the ''BlockEntityClientSerializable'' interface from the Fabric API. You might also want to have a look at the ''BlockEntityClientSerializable'' interface from the Fabric API.
  
tutorial/extendedscreenhandler.txt · Last modified: 2022/12/17 15:38 by miir