GrindstoneScreenRe.java 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package com.hexdragon.enchrebirth.block;
  2. import com.hexdragon.enchrebirth.EnchRebirth;
  3. import com.mojang.blaze3d.matrix.MatrixStack;
  4. import net.minecraft.client.gui.screen.inventory.ContainerScreen;
  5. import net.minecraft.entity.player.PlayerInventory;
  6. import net.minecraft.util.ResourceLocation;
  7. import net.minecraft.util.text.ITextComponent;
  8. import net.minecraftforge.api.distmarker.Dist;
  9. import net.minecraftforge.api.distmarker.OnlyIn;
  10. import org.lwjgl.opengl.GL11;
  11. @OnlyIn(Dist.CLIENT)
  12. public class GrindstoneScreenRe extends ContainerScreen<GrindstoneContainerRe> {
  13. private static final ResourceLocation GRINDSTONE_GUI_TEXTURES = new ResourceLocation(EnchRebirth.MODID, "textures/gui/container/grindstone.png");
  14. public GrindstoneScreenRe(GrindstoneContainerRe container, PlayerInventory playerInventory, ITextComponent textComponent) {
  15. super(container, playerInventory, textComponent);
  16. this.playerInventoryTitleY = 1000000; // 关闭显示
  17. this.titleX = 61; this.titleY = 12; this.ySize = 150;
  18. }
  19. public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
  20. this.renderBackground(matrixStack);
  21. this.drawGuiContainerBackgroundLayer(matrixStack, partialTicks, mouseX, mouseY);
  22. super.render(matrixStack, mouseX, mouseY, partialTicks);
  23. this.renderHoveredTooltip(matrixStack, mouseX, mouseY);
  24. }
  25. protected void drawGuiContainerBackgroundLayer(MatrixStack matrixStack, float partialTicks, int x, int y) {
  26. GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
  27. this.minecraft.getTextureManager().bindTexture(GRINDSTONE_GUI_TEXTURES);
  28. int i = (this.width - this.xSize) / 2;
  29. int j = (this.height - this.ySize) / 2;
  30. this.blit(matrixStack, i, j, 0, 0, this.xSize, this.ySize);
  31. // 显示无法合成的红叉:输入、输出仅一方为空
  32. if (this.container.getSlot(0).getHasStack() ^ (this.container.getSlot(1).getHasStack() || this.container.getSlot(2).getHasStack())) {
  33. this.blit(matrixStack, i + 85, j + 26, this.xSize, 0, 28, 21);
  34. }
  35. }
  36. }