Kaynağa Gözat

砂轮 GUI 去掉了 “物品栏” 的标题

LTCatt 6 yıl önce
ebeveyn
işleme
080bc73338

+ 24 - 0
src/main/java/com/hexdragon/core/gui/ContainerScreenRe.java

@@ -0,0 +1,24 @@
+package com.hexdragon.core.gui;
+
+import com.mojang.blaze3d.matrix.MatrixStack;
+import net.minecraft.client.gui.screen.inventory.ContainerScreen;
+import net.minecraft.entity.player.PlayerInventory;
+import net.minecraft.inventory.container.Container;
+import net.minecraft.util.text.ITextComponent;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
+
+@OnlyIn(Dist.CLIENT)
+public abstract class ContainerScreenRe<T extends Container> extends ContainerScreen<T> {
+    public ContainerScreenRe(Container screenContainer, PlayerInventory inv, ITextComponent titleIn) {super((T) screenContainer, inv, titleIn); }
+
+    // 提供扩展的 showPlayerInventoryTitle 属性:是否显示 “物品栏” 这一文本
+    public boolean showPlayerInventoryTitle = true;
+
+    @Override protected void drawGuiContainerForegroundLayer(MatrixStack matrixStack, int x, int y) {
+        this.font.func_243248_b(matrixStack, this.title, (float) this.titleX, (float) this.titleY, 4210752);
+        if (showPlayerInventoryTitle)
+            this.font.func_243248_b(matrixStack, this.playerInventory.getDisplayName(), (float) this.playerInventoryTitleX, (float) this.playerInventoryTitleY, 4210752);
+    }
+
+}

+ 3 - 2
src/main/java/com/hexdragon/enchrebirth/block/GrindstoneScreenRe.java

@@ -1,7 +1,7 @@
 package com.hexdragon.enchrebirth.block;
 
+import com.hexdragon.core.gui.ContainerScreenRe;
 import com.mojang.blaze3d.matrix.MatrixStack;
-import net.minecraft.client.gui.screen.inventory.ContainerScreen;
 import net.minecraft.entity.player.PlayerInventory;
 import net.minecraft.util.ResourceLocation;
 import net.minecraft.util.text.ITextComponent;
@@ -10,11 +10,12 @@ import net.minecraftforge.api.distmarker.OnlyIn;
 import org.lwjgl.opengl.GL11;
 
 @OnlyIn(Dist.CLIENT)
-public class GrindstoneScreenRe extends ContainerScreen<GrindstoneContainerRe> {
+public class GrindstoneScreenRe extends ContainerScreenRe<GrindstoneContainerRe> {
     private static final ResourceLocation GRINDSTONE_GUI_TEXTURES = new ResourceLocation("textures/gui/container/grindstone.png");
 
     public GrindstoneScreenRe(GrindstoneContainerRe container, PlayerInventory playerInventory, ITextComponent textComponent) {
         super(container, playerInventory, textComponent);
+        this.showPlayerInventoryTitle = false;
     }
 
     public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {