NaturesAura/src/main/java/de/ellpeck/naturesaura/gui/GuiEnderCrate.java

54 lines
2.4 KiB
Java
Raw Normal View History

2019-02-17 22:51:05 +01:00
package de.ellpeck.naturesaura.gui;
2020-01-21 23:02:39 +01:00
import com.mojang.blaze3d.platform.GlStateManager;
2019-02-17 22:51:05 +01:00
import de.ellpeck.naturesaura.NaturesAura;
2019-10-20 22:30:49 +02:00
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
2019-02-17 22:51:05 +01:00
import net.minecraft.client.resources.I18n;
2019-10-20 22:30:49 +02:00
import net.minecraft.entity.player.PlayerEntity;
2020-01-21 23:02:39 +01:00
import net.minecraft.inventory.container.ContainerType;
2019-02-17 22:51:05 +01:00
import net.minecraft.util.ResourceLocation;
2020-01-21 23:02:39 +01:00
import net.minecraft.util.text.StringTextComponent;
2019-02-17 22:51:05 +01:00
import net.minecraft.util.text.TextFormatting;
2019-10-20 22:30:49 +02:00
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
2019-02-18 12:15:18 +01:00
import net.minecraftforge.items.IItemHandler;
2019-02-17 22:51:05 +01:00
2019-10-20 22:30:49 +02:00
@OnlyIn(Dist.CLIENT)
public class GuiEnderCrate extends ContainerScreen {
2019-02-17 22:51:05 +01:00
private static final ResourceLocation CHEST_GUI_TEXTURE = new ResourceLocation("textures/gui/container/generic_54.png");
2019-10-20 22:30:49 +02:00
private final PlayerEntity player;
2019-02-18 12:15:18 +01:00
private final String nameKey;
private final String name;
2019-02-17 22:51:05 +01:00
2020-01-21 23:02:39 +01:00
public GuiEnderCrate(ContainerType<?> type, int id, PlayerEntity player, IItemHandler handler, String nameKey, String name) {
super(new ContainerEnderCrate(type, id, player, handler), player.inventory, new StringTextComponent(""));
2019-02-17 22:51:05 +01:00
this.player = player;
2019-02-18 12:15:18 +01:00
this.nameKey = nameKey;
this.name = name;
2019-02-17 22:51:05 +01:00
this.ySize = 114 + 3 * 18;
}
@Override
2020-01-21 23:02:39 +01:00
public void render(int mouseX, int mouseY, float partialTicks) {
this.renderBackground();
super.render(mouseX, mouseY, partialTicks);
2019-02-17 22:51:05 +01:00
this.renderHoveredToolTip(mouseX, mouseY);
}
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
2019-02-18 12:15:18 +01:00
String display = I18n.format("info." + NaturesAura.MOD_ID + "." + this.nameKey, TextFormatting.ITALIC + this.name + TextFormatting.RESET);
2020-01-21 23:02:39 +01:00
this.font.drawString(display, 8, 6, 4210752);
this.font.drawString(this.player.inventory.getDisplayName().getFormattedText(), 8, this.ySize - 96 + 2, 4210752);
2019-02-17 22:51:05 +01:00
}
@Override
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
2020-01-21 23:02:39 +01:00
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
this.getMinecraft().getTextureManager().bindTexture(CHEST_GUI_TEXTURE);
2019-02-17 22:51:05 +01:00
int i = (this.width - this.xSize) / 2;
int j = (this.height - this.ySize) / 2;
2020-01-21 23:02:39 +01:00
this.blit(i, j, 0, 0, this.xSize, 3 * 18 + 17);
this.blit(i, j + 3 * 18 + 17, 0, 126, this.xSize, 96);
2019-02-17 22:51:05 +01:00
}
}