From 431bee8aa78334214d1154778d994ec4d70f3ec2 Mon Sep 17 00:00:00 2001 From: kill05 Date: Sat, 15 Jun 2024 12:04:49 +0200 Subject: [PATCH] Fixed double chests not working --- .../java/turniplabs/halplibe/helper/gui/Guis.java | 11 ++++++----- .../halplibe/mixin/mixins/gui/BlockChestMixin.java | 4 ++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/turniplabs/halplibe/helper/gui/Guis.java b/src/main/java/turniplabs/halplibe/helper/gui/Guis.java index 7ff2d4f..93d22c3 100644 --- a/src/main/java/turniplabs/halplibe/helper/gui/Guis.java +++ b/src/main/java/turniplabs/halplibe/helper/gui/Guis.java @@ -2,6 +2,7 @@ import net.minecraft.client.entity.player.EntityPlayerSP; import net.minecraft.client.gui.*; +import net.minecraft.core.block.BlockChest; import net.minecraft.core.block.entity.*; import net.minecraft.core.entity.player.EntityPlayer; import net.minecraft.core.item.ItemStack; @@ -83,15 +84,15 @@ private int getSlot(EntityPlayer player, ItemStack itemStack) { Server Guis ============== */ - public static final RegisteredGui CHEST = GuiHelper.registerServerGui("minecraft", "chest", new TileGuiFactory() { + public static final RegisteredGui CHEST = GuiHelper.registerServerGui("minecraft", "chest", new BlockGuiFactory() { @Override - public @NotNull GuiScreen createGui(@NotNull RegisteredGui gui, @NotNull EntityPlayerSP player, @NotNull TileEntityChest tile) { - return new GuiChest(player.inventory, tile); + public @NotNull GuiScreen createGui(@NotNull RegisteredGui gui, @NotNull EntityPlayerSP player, int x, int y, int z) { + return new GuiChest(player.inventory, BlockChest.getInventory(player.world, x, y, z)); } @Override - public @NotNull Container createContainer(@NotNull RegisteredGui gui, @NotNull EntityPlayerMP player, @NotNull TileEntityChest tile) { - return new ContainerChest(player.inventory, tile); + public @NotNull Container createContainer(@NotNull RegisteredGui gui, @NotNull EntityPlayerMP player, int x, int y, int z) { + return new ContainerChest(player.inventory, BlockChest.getInventory(player.world, x, y, z)); } }); diff --git a/src/main/java/turniplabs/halplibe/mixin/mixins/gui/BlockChestMixin.java b/src/main/java/turniplabs/halplibe/mixin/mixins/gui/BlockChestMixin.java index 1ee6c3b..bbcd8a7 100644 --- a/src/main/java/turniplabs/halplibe/mixin/mixins/gui/BlockChestMixin.java +++ b/src/main/java/turniplabs/halplibe/mixin/mixins/gui/BlockChestMixin.java @@ -6,6 +6,7 @@ import net.minecraft.core.entity.player.EntityPlayer; import net.minecraft.core.world.World; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; import turniplabs.halplibe.helper.gui.Guis; @Mixin( @@ -14,12 +15,15 @@ ) public abstract class BlockChestMixin extends BlockTileEntity { + @Shadow public abstract void checkIfOtherHalfExists(World world, int x, int y, int z); + public BlockChestMixin(String key, int id, Material material) { super(key, id, material); } @Override public boolean blockActivated(World world, int x, int y, int z, EntityPlayer player) { + if(!world.isClientSide) checkIfOtherHalfExists(world, x, y, z); Guis.CHEST.open(player, x, y, z); return true; }