diff options
Diffstat (limited to 'src/main/java/lv/enes/mc/eris_alchemy/client/ChestLikeScreen.java')
| -rw-r--r-- | src/main/java/lv/enes/mc/eris_alchemy/client/ChestLikeScreen.java | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/main/java/lv/enes/mc/eris_alchemy/client/ChestLikeScreen.java b/src/main/java/lv/enes/mc/eris_alchemy/client/ChestLikeScreen.java new file mode 100644 index 0000000..c98b356 --- /dev/null +++ b/src/main/java/lv/enes/mc/eris_alchemy/client/ChestLikeScreen.java | |||
| @@ -0,0 +1,46 @@ | |||
| 1 | package lv.enes.mc.eris_alchemy.client; | ||
| 2 | |||
| 3 | import lv.enes.mc.eris_alchemy.menu.ChestLikeBlockMenu; | ||
| 4 | import net.minecraft.client.gui.GuiGraphics; | ||
| 5 | import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; | ||
| 6 | import net.minecraft.network.chat.Component; | ||
| 7 | import net.minecraft.resources.ResourceLocation; | ||
| 8 | import net.minecraft.world.entity.player.Inventory; | ||
| 9 | |||
| 10 | public abstract class ChestLikeScreen<M extends ChestLikeBlockMenu> extends AbstractContainerScreen<M> { | ||
| 11 | public ChestLikeScreen(M menu, Inventory inventory, Component title) { | ||
| 12 | super(menu, inventory, title); | ||
| 13 | |||
| 14 | imageWidth = getTextureWidth(); | ||
| 15 | imageHeight = getTextureHeight(); | ||
| 16 | } | ||
| 17 | |||
| 18 | protected abstract ResourceLocation getTexture(); | ||
| 19 | protected abstract int getTextureWidth(); | ||
| 20 | protected abstract int getTextureHeight(); | ||
| 21 | |||
| 22 | protected boolean shouldRenderLabels() { | ||
| 23 | return true; | ||
| 24 | } | ||
| 25 | |||
| 26 | @Override | ||
| 27 | public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) { | ||
| 28 | renderBackground(graphics); | ||
| 29 | super.render(graphics, mouseX, mouseY, delta); | ||
| 30 | renderTooltip(graphics, mouseX, mouseY); | ||
| 31 | } | ||
| 32 | |||
| 33 | @Override | ||
| 34 | protected void renderBg(GuiGraphics graphics, float delta, int mouseX, int mouseY) { | ||
| 35 | int x = (width - imageWidth) / 2; | ||
| 36 | int y = (height - imageHeight) / 2; | ||
| 37 | graphics.blit(getTexture(), x, y, 0, 0, imageWidth, imageHeight); | ||
| 38 | } | ||
| 39 | |||
| 40 | @Override | ||
| 41 | protected void renderLabels(GuiGraphics graphics, int mouseX, int mouseY) { | ||
| 42 | if (shouldRenderLabels()) { | ||
| 43 | super.renderLabels(graphics, mouseX, mouseY); | ||
| 44 | } | ||
| 45 | } | ||
| 46 | } | ||