Skip to content

Commit

Permalink
Fixed double chests not working
Browse files Browse the repository at this point in the history
  • Loading branch information
kill05 committed Jun 15, 2024
1 parent 00e6418 commit 431bee8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/main/java/turniplabs/halplibe/helper/gui/Guis.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -83,15 +84,15 @@ private int getSlot(EntityPlayer player, ItemStack itemStack) {
Server Guis
============== */

public static final RegisteredGui CHEST = GuiHelper.registerServerGui("minecraft", "chest", new TileGuiFactory<TileEntityChest>() {
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));
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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;
}
Expand Down

0 comments on commit 431bee8

Please sign in to comment.