tutorial:extendedscreenhandler
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorial:extendedscreenhandler [2020/08/15 18:55] – technici4n | tutorial:extendedscreenhandler [2022/12/17 15:38] (current) – [Registering our ScreenHandler] registry (f***) miir | ||
---|---|---|---|
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(" | + | |
+ | | ||
} else { | } else { | ||
return Optional.empty(); | return Optional.empty(); | ||
Line 152: | Line 157: | ||
[...] | [...] | ||
- | public static final ScreenHandlerType< | + | public static final ScreenHandlerType< |
static { | static { | ||
Line 158: | Line 163: | ||
//we now use registerExtended as our screenHandler now accepts a packetByteBuf in its Constructor | //we now use registerExtended as our screenHandler now accepts a packetByteBuf in its Constructor | ||
- | BOX_SCREEN_HANDLER = ScreenHandlerRegistry.registerExtended(BOX, BoxScreenHandler:: | + | BOX_SCREEN_HANDLER = Registry.register(Registries.SCREEN_HANDLER, new Identifier(" |
} | } | ||
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: | + | This is possible by sending custom Packets (see: [[tutorial: |
You might also want to have a look at the '' | You might also want to have a look at the '' | ||
tutorial/extendedscreenhandler.1597517714.txt.gz · Last modified: 2020/08/15 18:55 by technici4n