tutorial:screenhandler
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorial:screenhandler [2022/02/03 18:14] – change generic ScreenHandler argument in the BoxScreen to be the actual BoxScreenHandler glisco | tutorial:screenhandler [2024/02/19 02:51] (current) – [ScreenHandler and Screen] transferSlot -> quickMove per yarn mappings netuserget | ||
---|---|---|---|
Line 91: | Line 91: | ||
public DefaultedList< | public DefaultedList< | ||
return inventory; | return inventory; | ||
- | |||
} | } | ||
Line 107: | Line 106: | ||
@Override | @Override | ||
public Text getDisplayName() { | public Text getDisplayName() { | ||
- | return new TranslatableText(getCachedState().getBlock().getTranslationKey()); | + | |
+ | return Text.translatable(getCachedState().getBlock().getTranslationKey()); | ||
+ | // for earlier versions | ||
+ | // return new TranslatableText(getCachedState().getBlock().getTranslationKey()); | ||
} | } | ||
| | ||
Line 142: | Line 144: | ||
static { | static { | ||
- | BOX_BLOCK = Registry.register(Registry.BLOCK, BOX, new BoxBlock(FabricBlockSettings.copyOf(Blocks.CHEST))); | + | BOX_BLOCK = Registry.register(Registries.BLOCK, BOX, new BoxBlock(FabricBlockSettings.copyOf(Blocks.CHEST))); |
- | BOX_BLOCK_ITEM = Registry.register(Registry.ITEM, BOX, new BlockItem(BOX_BLOCK, | + | BOX_BLOCK_ITEM = Registry.register(Registries.ITEM, BOX, new BlockItem(BOX_BLOCK, |
//The parameter of build at the very end is always null, do not worry about it | //The parameter of build at the very end is always null, do not worry about it | ||
Line 215: | Line 217: | ||
// Shift + Player Inv Slot | // Shift + Player Inv Slot | ||
@Override | @Override | ||
- | public ItemStack | + | public ItemStack |
ItemStack newStack = ItemStack.EMPTY; | ItemStack newStack = ItemStack.EMPTY; | ||
Slot slot = this.slots.get(invSlot); | Slot slot = this.slots.get(invSlot); | ||
Line 253: | Line 255: | ||
@Override | @Override | ||
protected void drawBackground(MatrixStack matrices, float delta, int mouseX, int mouseY) { | protected void drawBackground(MatrixStack matrices, float delta, int mouseX, int mouseY) { | ||
- | RenderSystem.setShader(GameRenderer:: | + | RenderSystem.setShader(GameRenderer:: |
RenderSystem.setShaderColor(1.0F, | RenderSystem.setShaderColor(1.0F, | ||
RenderSystem.setShaderTexture(0, | RenderSystem.setShaderTexture(0, | ||
Line 259: | Line 261: | ||
int y = (height - backgroundHeight) / 2; | int y = (height - backgroundHeight) / 2; | ||
drawTexture(matrices, | drawTexture(matrices, | ||
+ | //in 1.20 or above,this method is in DrawContext class. | ||
} | } | ||
Line 288: | Line 291: | ||
@Override | @Override | ||
public void onInitializeClient() { | public void onInitializeClient() { | ||
- | | + | |
} | } | ||
} | } |
tutorial/screenhandler.1643912060.txt.gz · Last modified: 2022/02/03 18:14 by glisco