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