ソースを参照

修复部分导致接管附魔台 GUI 失败的 Bug

LTCatt 6 年 前
親
コミット
1031a58ffe

+ 2 - 2
src/main/java/com/hexdragon/enchre/block/enchantingtable/EnchantmentContainerRe.java

@@ -1,4 +1,5 @@
 package com.hexdragon.enchre.block.enchantingtable;
 package com.hexdragon.enchre.block.enchantingtable;
+import com.hexdragon.enchre.registry.RegMain;
 import net.minecraft.advancements.CriteriaTriggers;
 import net.minecraft.advancements.CriteriaTriggers;
 import net.minecraft.block.Blocks;
 import net.minecraft.block.Blocks;
 import net.minecraft.enchantment.EnchantmentData;
 import net.minecraft.enchantment.EnchantmentData;
@@ -9,7 +10,6 @@ import net.minecraft.entity.player.ServerPlayerEntity;
 import net.minecraft.inventory.IInventory;
 import net.minecraft.inventory.IInventory;
 import net.minecraft.inventory.Inventory;
 import net.minecraft.inventory.Inventory;
 import net.minecraft.inventory.container.Container;
 import net.minecraft.inventory.container.Container;
-import net.minecraft.inventory.container.ContainerType;
 import net.minecraft.inventory.container.Slot;
 import net.minecraft.inventory.container.Slot;
 import net.minecraft.item.EnchantedBookItem;
 import net.minecraft.item.EnchantedBookItem;
 import net.minecraft.item.ItemStack;
 import net.minecraft.item.ItemStack;
@@ -50,7 +50,7 @@ public class EnchantmentContainerRe extends Container {
     }
     }
 
 
     public EnchantmentContainerRe(int id, PlayerInventory playerInventory, IWorldPosCallable worldPosCallable) {
     public EnchantmentContainerRe(int id, PlayerInventory playerInventory, IWorldPosCallable worldPosCallable) {
-        super(ContainerType.ENCHANTMENT, id);
+        super(RegMain.containerEnchantment.get(), id);
         this.worldPosCallable = worldPosCallable;
         this.worldPosCallable = worldPosCallable;
         this.addSlot(new Slot(this.tableInventory, 0, 15, 47) {
         this.addSlot(new Slot(this.tableInventory, 0, 15, 47) {
             /**
             /**

+ 1 - 1
src/main/java/com/hexdragon/enchre/block/enchantingtable/EnchantmentScreenRe.java

@@ -140,7 +140,7 @@ public class EnchantmentScreenRe extends ContainerScreen<EnchantmentContainerRe>
         int l = this.container.getLapisAmount();
         int l = this.container.getLapisAmount();
 
 
         for(int i1 = 0; i1 < 3; ++i1) {
         for(int i1 = 0; i1 < 3; ++i1) {
-            int j1 = i + 60;
+            int j1 = i + 60 + 50; // TODO : 调试用的 50,确认替换
             int k1 = j1 + 20;
             int k1 = j1 + 20;
             this.setBlitOffset(0);
             this.setBlitOffset(0);
             this.minecraft.getTextureManager().bindTexture(ENCHANTMENT_TABLE_GUI_TEXTURE);
             this.minecraft.getTextureManager().bindTexture(ENCHANTMENT_TABLE_GUI_TEXTURE);

+ 4 - 2
src/main/java/com/hexdragon/enchre/mixin/block/EnchantingTableBlockMixin.java

@@ -1,4 +1,5 @@
 package com.hexdragon.enchre.mixin.block;
 package com.hexdragon.enchre.mixin.block;
+import com.hexdragon.enchre.block.enchantingtable.EnchantmentContainerRe;
 import net.minecraft.block.BlockState;
 import net.minecraft.block.BlockState;
 import net.minecraft.block.ContainerBlock;
 import net.minecraft.block.ContainerBlock;
 import net.minecraft.block.EnchantingTableBlock;
 import net.minecraft.block.EnchantingTableBlock;
@@ -13,16 +14,17 @@ import net.minecraft.util.text.TranslationTextComponent;
 import net.minecraft.world.World;
 import net.minecraft.world.World;
 import org.spongepowered.asm.mixin.Mixin;
 import org.spongepowered.asm.mixin.Mixin;
 import org.spongepowered.asm.mixin.Overwrite;
 import org.spongepowered.asm.mixin.Overwrite;
+import javax.annotation.Nullable;
 
 
 @Mixin(EnchantingTableBlock.class)
 @Mixin(EnchantingTableBlock.class)
 public abstract class EnchantingTableBlockMixin extends ContainerBlock {
 public abstract class EnchantingTableBlockMixin extends ContainerBlock {
     protected EnchantingTableBlockMixin(Properties builder) {super(builder);}
     protected EnchantingTableBlockMixin(Properties builder) {super(builder);}
 
 
     // 将附魔台的处理事件替换为 Mod 所提供的事件
     // 将附魔台的处理事件替换为 Mod 所提供的事件
-    @Overwrite public INamedContainerProvider getContainer(BlockState state, World worldIn, BlockPos pos) {
+    @Overwrite @Nullable public INamedContainerProvider getContainer(BlockState state, World worldIn, BlockPos pos) {
         TileEntity tileentity = worldIn.getTileEntity(pos);
         TileEntity tileentity = worldIn.getTileEntity(pos);
         if (tileentity instanceof EnchantingTableTileEntity) {
         if (tileentity instanceof EnchantingTableTileEntity) {
-            return new SimpleNamedContainerProvider((id, inventory, player) -> new EnchantmentContainer(id, inventory, IWorldPosCallable.of(worldIn, pos)), new TranslationTextComponent("gui.enchanting.title"));
+            return new SimpleNamedContainerProvider((id, inventory, player) -> new EnchantmentContainerRe(id, inventory, IWorldPosCallable.of(worldIn, pos)), new TranslationTextComponent("gui.enchanting.title"));
         } else {
         } else {
             return null;
             return null;
         }
         }