Browse Source

通过修改 playerInventoryTitleY 隐藏 “物品栏” 文字,顺便删了几个回车

LTCatt 6 years ago
parent
commit
64011cd886

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

@@ -1,24 +0,0 @@
-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);
-    }
-
-}

+ 0 - 11
src/main/java/com/hexdragon/core/item/CraftResultInventoryRe.java

@@ -16,12 +16,10 @@ public class CraftResultInventoryRe implements IInventory, IRecipeHolder {
     // 构造函数
     // 构造函数
     private final int slotsCount;
     private final int slotsCount;
     private final NonNullList<ItemStack> inventoryContents;
     private final NonNullList<ItemStack> inventoryContents;
-
     public CraftResultInventoryRe(int numSlots) {
     public CraftResultInventoryRe(int numSlots) {
         this.slotsCount = numSlots;
         this.slotsCount = numSlots;
         this.inventoryContents = NonNullList.withSize(numSlots, ItemStack.EMPTY);
         this.inventoryContents = NonNullList.withSize(numSlots, ItemStack.EMPTY);
     }
     }
-
     public CraftResultInventoryRe(ItemStack... stacksIn) {
     public CraftResultInventoryRe(ItemStack... stacksIn) {
         this.slotsCount = stacksIn.length;
         this.slotsCount = stacksIn.length;
         this.inventoryContents = NonNullList.from(ItemStack.EMPTY, stacksIn);
         this.inventoryContents = NonNullList.from(ItemStack.EMPTY, stacksIn);
@@ -29,7 +27,6 @@ public class CraftResultInventoryRe implements IInventory, IRecipeHolder {
 
 
     // 各种简单的方法
     // 各种简单的方法
     public int getSizeInventory() {return slotsCount;}
     public int getSizeInventory() {return slotsCount;}
-
     public boolean isEmpty() {
     public boolean isEmpty() {
         for (ItemStack itemstack : this.inventoryContents) {
         for (ItemStack itemstack : this.inventoryContents) {
             if (!itemstack.isEmpty()) {
             if (!itemstack.isEmpty()) {
@@ -38,27 +35,19 @@ public class CraftResultInventoryRe implements IInventory, IRecipeHolder {
         }
         }
         return true;
         return true;
     }
     }
-
     public void clear() {this.inventoryContents.clear();}
     public void clear() {this.inventoryContents.clear();}
-
     public void markDirty() {}
     public void markDirty() {}
-
     public boolean isUsableByPlayer(PlayerEntity player) {return true;}
     public boolean isUsableByPlayer(PlayerEntity player) {return true;}
 
 
     // 对物品格子的输入输出
     // 对物品格子的输入输出
     public ItemStack getStackInSlot(int index) {return this.inventoryContents.get(index);}
     public ItemStack getStackInSlot(int index) {return this.inventoryContents.get(index);}
-
     public void setInventorySlotContents(int index, ItemStack stack) {this.inventoryContents.set(index, stack);}
     public void setInventorySlotContents(int index, ItemStack stack) {this.inventoryContents.set(index, stack);}
-
     public ItemStack removeStackFromSlot(int index) {return ItemStackHelper.getAndRemove(this.inventoryContents, index);}
     public ItemStack removeStackFromSlot(int index) {return ItemStackHelper.getAndRemove(this.inventoryContents, index);}
-
     public ItemStack decrStackSize(int index, int count) {return ItemStackHelper.getAndRemove(this.inventoryContents, index);}
     public ItemStack decrStackSize(int index, int count) {return ItemStackHelper.getAndRemove(this.inventoryContents, index);}
 
 
     // 不知道有啥用的 Recipe 支持
     // 不知道有啥用的 Recipe 支持
     @Nullable private IRecipe<?> recipeUsed;
     @Nullable private IRecipe<?> recipeUsed;
-
     public void setRecipeUsed(@Nullable IRecipe<?> recipe) {this.recipeUsed = recipe;}
     public void setRecipeUsed(@Nullable IRecipe<?> recipe) {this.recipeUsed = recipe;}
-
     @Nullable public IRecipe<?> getRecipeUsed() {return this.recipeUsed;}
     @Nullable public IRecipe<?> getRecipeUsed() {return this.recipeUsed;}
 
 
 }
 }

+ 2 - 6
src/main/java/com/hexdragon/enchrebirth/block/GrindstoneContainerRe.java

@@ -40,9 +40,7 @@ public class GrindstoneContainerRe extends Container {
         });
         });
         this.addSlot(new Slot(this.outputInventory, 0, 120, 28) {
         this.addSlot(new Slot(this.outputInventory, 0, 120, 28) {
             // 禁止将物品放在输出格
             // 禁止将物品放在输出格
-            public boolean isItemValid(ItemStack stack) {
-                return false;
-            }
+            public boolean isItemValid(ItemStack stack) {return false;}
 
 
             // 从输出格拿走物品时清空输入格
             // 从输出格拿走物品时清空输入格
             public ItemStack onTake(PlayerEntity thePlayer, ItemStack stack) {
             public ItemStack onTake(PlayerEntity thePlayer, ItemStack stack) {
@@ -52,9 +50,7 @@ public class GrindstoneContainerRe extends Container {
         });
         });
         this.addSlot(new Slot(this.outputInventory, 1, 120 + 18, 28) {
         this.addSlot(new Slot(this.outputInventory, 1, 120 + 18, 28) {
             // 禁止将物品放在输出格
             // 禁止将物品放在输出格
-            public boolean isItemValid(ItemStack stack) {
-                return false;
-            }
+            public boolean isItemValid(ItemStack stack) {return false;}
 
 
             // 从输出格拿走物品时清空输入格
             // 从输出格拿走物品时清空输入格
             public ItemStack onTake(PlayerEntity thePlayer, ItemStack stack) {
             public ItemStack onTake(PlayerEntity thePlayer, ItemStack stack) {

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

@@ -1,8 +1,8 @@
 package com.hexdragon.enchrebirth.block;
 package com.hexdragon.enchrebirth.block;
 
 
-import com.hexdragon.core.gui.ContainerScreenRe;
 import com.hexdragon.enchrebirth.EnchRebirth;
 import com.hexdragon.enchrebirth.EnchRebirth;
 import com.mojang.blaze3d.matrix.MatrixStack;
 import com.mojang.blaze3d.matrix.MatrixStack;
+import net.minecraft.client.gui.screen.inventory.ContainerScreen;
 import net.minecraft.entity.player.PlayerInventory;
 import net.minecraft.entity.player.PlayerInventory;
 import net.minecraft.util.ResourceLocation;
 import net.minecraft.util.ResourceLocation;
 import net.minecraft.util.text.ITextComponent;
 import net.minecraft.util.text.ITextComponent;
@@ -11,12 +11,12 @@ import net.minecraftforge.api.distmarker.OnlyIn;
 import org.lwjgl.opengl.GL11;
 import org.lwjgl.opengl.GL11;
 
 
 @OnlyIn(Dist.CLIENT)
 @OnlyIn(Dist.CLIENT)
-public class GrindstoneScreenRe extends ContainerScreenRe<GrindstoneContainerRe> {
+public class GrindstoneScreenRe extends ContainerScreen<GrindstoneContainerRe> {
     private static final ResourceLocation GRINDSTONE_GUI_TEXTURES = new ResourceLocation(EnchRebirth.MODID, "textures/gui/container/grindstone.png");
     private static final ResourceLocation GRINDSTONE_GUI_TEXTURES = new ResourceLocation(EnchRebirth.MODID, "textures/gui/container/grindstone.png");
 
 
     public GrindstoneScreenRe(GrindstoneContainerRe container, PlayerInventory playerInventory, ITextComponent textComponent) {
     public GrindstoneScreenRe(GrindstoneContainerRe container, PlayerInventory playerInventory, ITextComponent textComponent) {
         super(container, playerInventory, textComponent);
         super(container, playerInventory, textComponent);
-        this.showPlayerInventoryTitle = false;
+        this.playerInventoryTitleY = 1000000; // 关闭显示
         this.titleX = 61; this.titleY = 12; this.ySize = 150;
         this.titleX = 61; this.titleY = 12; this.ySize = 150;
     }
     }