Skip to content

Commit

Permalink
Merge pull request #58 from kill05/7.2
Browse files Browse the repository at this point in the history
Fixed double chests
  • Loading branch information
MartinSVK12 authored Jun 15, 2024
2 parents e0cb7a5 + 431bee8 commit 3786ddd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 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 @@ -5,15 +5,13 @@
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;
import turniplabs.halplibe.helper.gui.packet.PacketOpenGui;
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);
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 3786ddd

Please sign in to comment.