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/helper/gui/factory/IGuiFactory.java b/src/main/java/turniplabs/halplibe/helper/gui/factory/IGuiFactory.java index 804441e..289955d 100644 --- a/src/main/java/turniplabs/halplibe/helper/gui/factory/IGuiFactory.java +++ b/src/main/java/turniplabs/halplibe/helper/gui/factory/IGuiFactory.java @@ -5,7 +5,6 @@ import net.minecraft.core.item.ItemStack; import net.minecraft.core.player.inventory.Container; import net.minecraft.server.entity.player.EntityPlayerMP; -import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import turniplabs.halplibe.helper.gui.packet.PacketOpenBlockGui; @@ -13,7 +12,6 @@ import turniplabs.halplibe.helper.gui.packet.PacketOpenItemGui; import turniplabs.halplibe.helper.gui.registered.RegisteredGui; -@ApiStatus.Internal public interface IGuiFactory { @NotNull GuiScreen createGui(@NotNull RegisteredGui gui, @NotNull EntityPlayerSP player, @Nullable ItemStack itemStack, int x, int y, int 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; }