From 5534531416388c50feeb6fd1cadb8f53b36045a1 Mon Sep 17 00:00:00 2001 From: Sen Date: Sat, 31 May 2025 18:38:53 +0200 Subject: [PATCH] make guis more generic --- .../client/gui/container/GuiContainer.java | 2 +- .../java/client/gui/container/GuiEnchant.java | 9 +- .../{GuiHorse.java => GuiEntity.java} | 35 +--- .../java/client/gui/container/GuiMachine.java | 44 ----- .../java/client/gui/container/GuiTile.java | 32 ++++ .../java/client/network/ClientPlayer.java | 171 +++++++----------- .../java/client/network/DummyContainer.java | 12 -- .../main/java/client/network/DummyPlayer.java | 23 +-- .../java/client/network/LocalContainer.java | 50 +++++ .../java/common/block/tech/BlockMachine.java | 10 +- .../common/entity/animal/EntityHorse.java | 2 +- .../java/common/entity/npc/EntityNPC.java | 25 +-- .../inventory/ContainerEntityInventory.java | 132 ++++++++++++++ .../inventory/ContainerHorseInventory.java | 129 ------------- .../common/inventory/ContainerLocalMenu.java | 59 ------ ...ntainerMachine.java => ContainerTile.java} | 32 ++-- .../java/common/network/IClientPlayer.java | 13 -- .../src/main/java/common/network/IPlayer.java | 3 +- .../java/common/packet/SPacketOpenWindow.java | 13 +- ...tityMachine.java => TileEntityDevice.java} | 24 +-- .../tileentity/TileEntityTianReactor.java | 2 +- .../src/main/java/server/network/Player.java | 16 +- 22 files changed, 334 insertions(+), 504 deletions(-) rename client/src/main/java/client/gui/container/{GuiHorse.java => GuiEntity.java} (56%) delete mode 100755 client/src/main/java/client/gui/container/GuiMachine.java create mode 100755 client/src/main/java/client/gui/container/GuiTile.java delete mode 100755 client/src/main/java/client/network/DummyContainer.java create mode 100755 client/src/main/java/client/network/LocalContainer.java create mode 100755 common/src/main/java/common/inventory/ContainerEntityInventory.java delete mode 100755 common/src/main/java/common/inventory/ContainerHorseInventory.java delete mode 100755 common/src/main/java/common/inventory/ContainerLocalMenu.java rename common/src/main/java/common/inventory/{ContainerMachine.java => ContainerTile.java} (77%) rename common/src/main/java/common/tileentity/{TileEntityMachine.java => TileEntityDevice.java} (92%) diff --git a/client/src/main/java/client/gui/container/GuiContainer.java b/client/src/main/java/client/gui/container/GuiContainer.java index 7fe7cfd..7f1eeff 100755 --- a/client/src/main/java/client/gui/container/GuiContainer.java +++ b/client/src/main/java/client/gui/container/GuiContainer.java @@ -1077,7 +1077,7 @@ public abstract class GuiContainer extends Gui if (this.gm != null && this.gm.player != null && (!this.gm.player.isEntityAlive() || this.gm.player.dead)) { - this.gm.player.closeScreen(); + this.gm.displayGuiScreen(null); } } diff --git a/client/src/main/java/client/gui/container/GuiEnchant.java b/client/src/main/java/client/gui/container/GuiEnchant.java index 0b25ef3..837bb02 100755 --- a/client/src/main/java/client/gui/container/GuiEnchant.java +++ b/client/src/main/java/client/gui/container/GuiEnchant.java @@ -5,7 +5,6 @@ import common.enchantment.Enchantment; import common.inventory.ContainerEnchantment; import common.inventory.InventoryPlayer; import common.rng.Random; -import common.tileentity.IWorldNameable; import common.world.World; public class GuiEnchant extends GuiContainer @@ -19,7 +18,7 @@ public class GuiEnchant extends GuiContainer private final Random nameRand = new Random(); private final Random random = new Random(); private final ContainerEnchantment container; - private final IWorldNameable table; + private final String title; // public int field_147073_u; // public float field_147071_v; @@ -30,12 +29,12 @@ public class GuiEnchant extends GuiContainer // public float field_147076_A; // ItemStack field_147077_B; - public GuiEnchant(InventoryPlayer inventory, World worldIn, IWorldNameable table) + public GuiEnchant(InventoryPlayer inventory, World worldIn, String title) { super(new ContainerEnchantment(inventory, worldIn)); this.playerInventory = inventory; this.container = (ContainerEnchantment)this.inventorySlots; - this.table = table; + this.title = title; } /** @@ -43,7 +42,7 @@ public class GuiEnchant extends GuiContainer */ public void drawGuiContainerForegroundLayer() { - this.drawString(this.table.getCommandName(), 12, 5); + this.drawString(this.title, 12, 5); this.drawString(this.playerInventory.getCommandName(), 8, this.ySize - 96 + 2); } diff --git a/client/src/main/java/client/gui/container/GuiHorse.java b/client/src/main/java/client/gui/container/GuiEntity.java similarity index 56% rename from client/src/main/java/client/gui/container/GuiHorse.java rename to client/src/main/java/client/gui/container/GuiEntity.java index ad5cf54..a4aa4bb 100755 --- a/client/src/main/java/client/gui/container/GuiHorse.java +++ b/client/src/main/java/client/gui/container/GuiEntity.java @@ -1,45 +1,26 @@ package client.gui.container; import client.Client; -import common.entity.animal.EntityHorse; -import common.inventory.ContainerHorseInventory; +import common.entity.Entity; +import common.inventory.ContainerEntityInventory; import common.inventory.IInventory; -public class GuiHorse extends GuiContainer +public class GuiEntity extends GuiContainer { -// private static final String horseGuiTextures = "textures/gui/horse.png"; - - /** The player inventory bound to this GUI. */ private IInventory playerInventory; + private IInventory entityInventory; - /** The horse inventory bound to this GUI. */ - private IInventory horseInventory; - -// /** The EntityHorse whose inventory is currently being accessed. */ -// private EntityHorse horseEntity; - -// /** The mouse x-position recorded during the last rendered frame. */ -// private float mousePosx; -// -// /** The mouse y-position recorded during the last renderered frame. */ -// private float mousePosY; - - public GuiHorse(IInventory playerInv, IInventory horseInv, EntityHorse horse) + public GuiEntity(IInventory playerInv, IInventory entityInv, Entity entity) { - super(new ContainerHorseInventory(playerInv, horseInv, horse, Client.CLIENT.player)); + super(new ContainerEntityInventory(playerInv, entityInv, entity, Client.CLIENT.player)); this.playerInventory = playerInv; - this.horseInventory = horseInv; -// this.horseEntity = horse; -// this.allowUserInput = false; + this.entityInventory = entityInv; } - /** - * Draw the foreground layer for the GuiContainer (everything in front of the items). Args : mouseX, mouseY - */ public void drawGuiContainerForegroundLayer() { - this.drawString(this.horseInventory.getCommandName(), 8, 6); + this.drawString(this.entityInventory.getCommandName(), 8, 6); this.drawString(this.playerInventory.getCommandName(), 8, this.ySize - 96 + 2); } diff --git a/client/src/main/java/client/gui/container/GuiMachine.java b/client/src/main/java/client/gui/container/GuiMachine.java deleted file mode 100755 index 2467e18..0000000 --- a/client/src/main/java/client/gui/container/GuiMachine.java +++ /dev/null @@ -1,44 +0,0 @@ -package client.gui.container; - -import client.Client; -import common.inventory.ContainerMachine; -import common.inventory.IInventory; -import common.inventory.InventoryPlayer; -import common.tileentity.TileEntityMachine; - - -public class GuiMachine extends GuiContainer -{ -// private final String texture; - private final IInventory playerInv; - private final IInventory machineInv; - private final TileEntityMachine machine; - - public GuiMachine(InventoryPlayer player, IInventory inv, TileEntityMachine machine) - { - super(new ContainerMachine(player, machine, inv, Client.CLIENT.player)); - this.playerInv = player; - this.machineInv = machine; -// this.allowUserInput = false; - this.ySize = 153; -// this.texture = "textures/gui/" + texture + ".png"; - this.machine = machine; - } - - public void drawGuiContainerForegroundLayer() - { - this.drawString(this.machine.getStatus().color + this.machineInv.getCommandName() + " - " + this.machine.getStatus().name, 8, 6); - this.drawString(this.playerInv.getCommandName(), 8, this.ySize - 96 + 2); - this.drawString(String.format("Temperatur: %d °", this.machine.getTemperature()), 8, 18); - this.drawString(this.machine.formatDisplay(), 8, 28); - } - -// protected void drawGuiContainerBackgroundLayer(int mouseX, int mouseY) -// { -// GlState.color(1.0F, 1.0F, 1.0F, 1.0F); -// this.gm.getTextureManager().bindTexture(this.texture); -// int i = (this.width - this.xSize) / 2; -// int j = (this.height - this.ySize) / 2; -//// this.rect(i, j, 0, 0, this.xSize, this.ySize); -// } -} diff --git a/client/src/main/java/client/gui/container/GuiTile.java b/client/src/main/java/client/gui/container/GuiTile.java new file mode 100755 index 0000000..c5a0591 --- /dev/null +++ b/client/src/main/java/client/gui/container/GuiTile.java @@ -0,0 +1,32 @@ +package client.gui.container; + +import client.Client; +import common.inventory.ContainerTile; +import common.inventory.IInventory; +import common.inventory.InventoryPlayer; +import common.tileentity.TileEntityDevice; + + +public class GuiTile extends GuiContainer +{ + private final IInventory playerInv; + private final IInventory tileInv; + private final TileEntityDevice tile; + + public GuiTile(InventoryPlayer player, IInventory inv, TileEntityDevice tile) + { + super(new ContainerTile(player, tile, inv, Client.CLIENT.player)); + this.playerInv = player; + this.tileInv = tile; + this.ySize = 153; + this.tile = tile; + } + + public void drawGuiContainerForegroundLayer() + { + this.drawString(this.tile.getStatus().color + this.tileInv.getCommandName() + " - " + this.tile.getStatus().name, 8, 6); + this.drawString(this.playerInv.getCommandName(), 8, this.ySize - 96 + 2); + this.drawString(String.format("Temperatur: %d °", this.tile.getTemperature()), 8, 18); + this.drawString(this.tile.formatDisplay(), 8, 28); + } +} diff --git a/client/src/main/java/client/network/ClientPlayer.java b/client/src/main/java/client/network/ClientPlayer.java index b07ef0d..bca28f5 100755 --- a/client/src/main/java/client/network/ClientPlayer.java +++ b/client/src/main/java/client/network/ClientPlayer.java @@ -15,8 +15,8 @@ import client.gui.container.GuiDispenser; import client.gui.container.GuiEnchant; import client.gui.container.GuiFurnace; import client.gui.container.GuiHopper; -import client.gui.container.GuiHorse; -import client.gui.container.GuiMachine; +import client.gui.container.GuiEntity; +import client.gui.container.GuiTile; import client.gui.container.GuiMerchant; import client.gui.container.GuiRepair; import client.gui.ingame.GuiSign; @@ -35,7 +35,6 @@ import common.block.tech.BlockWorkbench; import common.dimension.Dimension; import common.entity.DataWatcher; import common.entity.Entity; -import common.entity.animal.EntityHorse; import common.entity.effect.EntityLightning; import common.entity.item.EntityBoat; import common.entity.item.EntityXp; @@ -49,8 +48,6 @@ import common.init.ItemRegistry; import common.init.SoundEvent; import common.inventory.AnimalChest; import common.inventory.Container; -import common.inventory.ContainerLocalMenu; -import common.inventory.IInventory; import common.inventory.InventoryBasic; import common.inventory.InventoryPlayer; import common.item.ItemStack; @@ -128,11 +125,9 @@ import common.packet.SPacketWorld; import common.potion.PotionEffect; import common.rng.Random; import common.sound.Sound; -import common.tileentity.IInteractionObject; import common.tileentity.TileEntity; -import common.tileentity.TileEntityMachine; +import common.tileentity.TileEntityDevice; import common.tileentity.TileEntitySign; -import common.util.BlockPos; import common.village.MerchantRecipeList; import common.world.Explosion; import common.world.Weather; @@ -188,10 +183,6 @@ public class ClientPlayer implements IClientPlayer public final void updatePlayerMoveState() { this.gm.updatePlayerMoveState(); } - - public final void closeGui() { - this.gm.displayGuiScreen(null); - } public final NetConnection getConnection() { return this.connection; @@ -1118,53 +1109,79 @@ public class ClientPlayer implements IClientPlayer * Displays a GUI by ID. In order starting from id 0: Chest, Workbench, Furnace, Dispenser, Enchanting table, * Brewing stand, Villager merchant, Beacon, Anvil, Hopper, Dropper, Horse */ - public void handleOpenWindow(SPacketOpenWindow packetIn) + public void handleOpenWindow(SPacketOpenWindow packet) { - NetHandler.checkThread(packetIn, this, this.gm, this.world); - EntityNPC entityplayersp = this.gm.player; + NetHandler.checkThread(packet, this, this.gm, this.world); + EntityNPC player = this.gm.player; + String id = packet.getGuiId(); + String title = packet.getWindowTitle(); + int slots = packet.getSlotCount(); + LocalContainer local = new LocalContainer(title, slots); - if ("container".equals(packetIn.getGuiId())) + if ("container".equals(id)) { - entityplayersp.displayGUIChest(new InventoryBasic(packetIn.getWindowTitle(), packetIn.getSlotCount())); - entityplayersp.openContainer.windowId = packetIn.getWindowId(); + this.gm.displayGuiScreen(new GuiChest(player.inventory, new InventoryBasic(title, slots))); } - else if ("trade".equals(packetIn.getGuiId())) + else if ("enchanting_table".equals(id)) { - entityplayersp.displayTradeGui(packetIn.getWindowTitle()); - entityplayersp.openContainer.windowId = packetIn.getWindowId(); + this.gm.displayGuiScreen(new GuiEnchant(player.inventory, player.worldObj, title)); } - else if ("EntityHorse".equals(packetIn.getGuiId())) + else if ("anvil".equals(id)) { - Entity entity = this.world.getEntityByID(packetIn.getEntityId()); - - if (entity instanceof EntityHorse) - { - entityplayersp.displayGUIHorse((EntityHorse)entity, new AnimalChest(packetIn.getWindowTitle(), true, packetIn.getSlotCount())); - entityplayersp.openContainer.windowId = packetIn.getWindowId(); - } + this.gm.displayGuiScreen(new GuiRepair(player.inventory, player.worldObj)); } - else if (!packetIn.hasSlots()) + else if ("chest".equals(id)) { - entityplayersp.displayGui(new DummyContainer(packetIn.getGuiId(), packetIn.getWindowTitle())); - entityplayersp.openContainer.windowId = packetIn.getWindowId(); + this.gm.displayGuiScreen(new GuiChest(player.inventory, local)); + } + else if ("hopper".equals(id)) + { + this.gm.displayGuiScreen(new GuiHopper(player.inventory, local)); + } + else if ("furnace".equals(id)) + { + this.gm.displayGuiScreen(new GuiFurnace(player.inventory, local)); + } + else if ("brewing_stand".equals(id)) + { + this.gm.displayGuiScreen(new GuiBrewing(player.inventory, local)); + } + else if ("dispenser".equals(id) || "dropper".equals(id)) + { + this.gm.displayGuiScreen(new GuiDispenser(player.inventory, local)); + } + else if ("trade".equals(id)) + { + this.gm.displayGuiScreen(new GuiMerchant(player.inventory, title, player.worldObj)); + } + else if ("entity".equals(id)) + { + Entity entity = this.world.getEntityByID(packet.getEntityId()); + if(entity == null) + return; + this.gm.displayGuiScreen(new GuiEntity(player.inventory, new AnimalChest(title, true, slots), entity)); + } + else if ("tile".equals(id)) + { + TileEntity tile = this.world.getTileEntity(packet.getTilePos()); + if(!(tile instanceof TileEntityDevice)) + return; + this.gm.displayGuiScreen(new GuiTile(this.gm.player.inventory, local, (TileEntityDevice)tile)); } else { - ContainerLocalMenu containerlocalmenu = new ContainerLocalMenu(packetIn.getGuiId(), packetIn.getWindowTitle(), packetIn.getSlotCount()); - if (packetIn.getGuiId().startsWith("machine_")) - { - TileEntity machine = this.world.getTileEntity(packetIn.getTilePos()); - if(machine instanceof TileEntityMachine) - this.gm.displayGuiScreen(new GuiMachine(this.gm.player.inventory, containerlocalmenu, (TileEntityMachine)machine)); - } - else { - entityplayersp.displayGUIChest(containerlocalmenu); - } - entityplayersp.openContainer.windowId = packetIn.getWindowId(); + Block block = BlockRegistry.getRegisteredBlock(id); + if(block instanceof BlockWorkbench) { + this.gm.displayGuiScreen(new GuiCrafting(player.inventory, player.worldObj, (BlockWorkbench)block)); + } + else { + this.gm.displayGuiScreen(new GuiChest(player.inventory, local)); + } } + player.openContainer.windowId = packet.getWindowId(); } - - /** + + /** * Handles pickin up an ItemStack or dropping one in your inventory or an open container */ public void handleSetSlot(SPacketSetSlot packetIn) @@ -1262,7 +1279,7 @@ public class ClientPlayer implements IClientPlayer tileentity.setPos(packetIn.getSignPosition()); } - this.gm.player.openEditSign((TileEntitySign)tileentity); + this.gm.displayGuiScreen(new GuiSign(packetIn.getSignPosition(), ((TileEntitySign)tileentity).signText)); } public void handleForm(SPacketDisplayForm packet) { @@ -1959,66 +1976,4 @@ public class ClientPlayer implements IClientPlayer this.world.dimension.setFullName(packetIn.getFullName()); this.world.dimension.setCustomName(packetIn.getCustomName()); } - - public void displayGUIChest(IInventory chestInventory, InventoryPlayer inventory) { - String s = chestInventory instanceof IInteractionObject ? ((IInteractionObject)chestInventory).getGuiID() : "container"; - - if ("chest".equals(s)) - { - this.gm.displayGuiScreen(new GuiChest(inventory, chestInventory)); - } - else if ("hopper".equals(s)) - { - this.gm.displayGuiScreen(new GuiHopper(inventory, chestInventory)); - } - else if ("furnace".equals(s)) - { - this.gm.displayGuiScreen(new GuiFurnace(inventory, chestInventory)); - } - else if ("brewing_stand".equals(s)) - { - this.gm.displayGuiScreen(new GuiBrewing(inventory, chestInventory)); - } -// else if ("beacon".equals(s)) -// { -// this.gm.displayGuiScreen(new GuiBeacon(this.inventory, chestInventory)); -// } - else if (!"dispenser".equals(s) && !"dropper".equals(s)) - { - this.gm.displayGuiScreen(new GuiChest(inventory, chestInventory)); - } - else - { - this.gm.displayGuiScreen(new GuiDispenser(inventory, chestInventory)); - } - } - - public void displayGui(IInteractionObject guiOwner, InventoryPlayer inventory, World worldObj) { - String s = guiOwner.getGuiID(); - - Block block = BlockRegistry.getRegisteredBlock(s); - if(block instanceof BlockWorkbench) { - this.gm.displayGuiScreen(new GuiCrafting(inventory, worldObj, (BlockWorkbench)block)); - } - else if ("enchanting_table".equals(s)) - { - this.gm.displayGuiScreen(new GuiEnchant(inventory, worldObj, guiOwner)); - } - else if ("anvil".equals(s)) - { - this.gm.displayGuiScreen(new GuiRepair(inventory, worldObj)); - } - } - - public void displayGuiHorse(EntityHorse horse, InventoryPlayer inventory, IInventory horseInventory) { - this.gm.displayGuiScreen(new GuiHorse(inventory, horseInventory, horse)); - } - - public void displayGuiMerchant(String title, InventoryPlayer inventory, World worldObj) { - this.gm.displayGuiScreen(new GuiMerchant(inventory, title, worldObj)); - } - - public void displayGuiSign(BlockPos pos, String[] text) { - this.gm.displayGuiScreen(new GuiSign(pos, text)); - } } diff --git a/client/src/main/java/client/network/DummyContainer.java b/client/src/main/java/client/network/DummyContainer.java deleted file mode 100755 index 634ce22..0000000 --- a/client/src/main/java/client/network/DummyContainer.java +++ /dev/null @@ -1,12 +0,0 @@ -package client.network; - -import common.entity.npc.EntityNPC; -import common.inventory.Container; -import common.inventory.InventoryPlayer; -import common.tileentity.IInteractionObject; - -public record DummyContainer(String getGuiID, String getCommandName) implements IInteractionObject { - public Container createContainer(InventoryPlayer playerInventory, EntityNPC playerIn) { - throw new UnsupportedOperationException(); - } -} diff --git a/client/src/main/java/client/network/DummyPlayer.java b/client/src/main/java/client/network/DummyPlayer.java index ab5be6a..7aa77a5 100644 --- a/client/src/main/java/client/network/DummyPlayer.java +++ b/client/src/main/java/client/network/DummyPlayer.java @@ -5,11 +5,8 @@ import client.util.DummyController; import client.world.WorldClient; import common.dimension.Space; import common.entity.Entity; -import common.entity.animal.EntityHorse; import common.entity.npc.EntityCpu; import common.init.EntityRegistry; -import common.inventory.IInventory; -import common.inventory.InventoryPlayer; import common.model.ParticleType; import common.network.Packet; import common.packet.SPacketEntity; @@ -77,9 +74,6 @@ import common.packet.SPacketWorld; import common.potion.Potion; import common.potion.PotionEffect; import common.sound.Sound; -import common.tileentity.IInteractionObject; -import common.util.BlockPos; -import common.world.World; public class DummyPlayer extends ClientPlayer { public DummyPlayer(Client gm) { @@ -102,6 +96,7 @@ public class DummyPlayer extends ClientPlayer { world.setTimeFactor(this.gm.timeFactor = 1); this.gm.dayCycle = true; } + public void cleanup() { } @@ -112,26 +107,12 @@ public class DummyPlayer extends ClientPlayer { public void emitParticleAtEntity(Entity entityIn, ParticleType particleTypes) { } - public void displayGUIChest(IInventory chestInventory, InventoryPlayer inventory) { - } - - public void displayGui(IInteractionObject guiOwner, InventoryPlayer inventory, World worldObj) { - } - - public void displayGuiHorse(EntityHorse horse, InventoryPlayer inventory, IInventory horseInventory) { - } - - public void displayGuiMerchant(String title, InventoryPlayer inventory, World worldObj) { - } - - public void displayGuiSign(BlockPos pos, String[] text) { - } - public void onDisconnect(String reason) { } public void addToSendQueue(Packet packet) { } + public void handleJoinGame(SPacketJoinGame packetIn) { } diff --git a/client/src/main/java/client/network/LocalContainer.java b/client/src/main/java/client/network/LocalContainer.java new file mode 100755 index 0000000..80653a1 --- /dev/null +++ b/client/src/main/java/client/network/LocalContainer.java @@ -0,0 +1,50 @@ +package client.network; + +import java.util.Map; + +import common.collect.Maps; +import common.entity.npc.EntityNPC; +import common.inventory.Container; +import common.inventory.InventoryBasic; +import common.inventory.InventoryPlayer; +import common.tileentity.ILockableContainer; +import common.tileentity.Passcode; + +public class LocalContainer extends InventoryBasic implements ILockableContainer { + private Map fields = Maps.newHashMap(); + + public LocalContainer(String title, int slotCount) { + super(title, slotCount); + } + + public int getField(int id) { + return this.fields.containsKey(Integer.valueOf(id)) ? ((Integer)this.fields.get(Integer.valueOf(id))).intValue() : 0; + } + + public void setField(int id, int value) { + this.fields.put(Integer.valueOf(id), Integer.valueOf(value)); + } + + public int getFieldCount() { + return this.fields.size(); + } + + public boolean isLocked() { + return false; + } + + public void setLockCode(Passcode code) { + } + + public Passcode getLockCode() { + return Passcode.EMPTY_CODE; + } + + public String getGuiID() { + return null; + } + + public Container createContainer(InventoryPlayer playerInventory, EntityNPC playerIn) { + throw new UnsupportedOperationException(); + } +} diff --git a/common/src/main/java/common/block/tech/BlockMachine.java b/common/src/main/java/common/block/tech/BlockMachine.java index 3275f8d..efdf9c3 100755 --- a/common/src/main/java/common/block/tech/BlockMachine.java +++ b/common/src/main/java/common/block/tech/BlockMachine.java @@ -11,7 +11,7 @@ import common.inventory.InventoryHelper; import common.item.CheatTab; import common.properties.IProperty; import common.tileentity.TileEntity; -import common.tileentity.TileEntityMachine; +import common.tileentity.TileEntityDevice; import common.util.BlockPos; import common.util.Facing; import common.world.State; @@ -37,8 +37,8 @@ public abstract class BlockMachine extends BlockDirectional implements ITileEnti if(worldIn.client) return true; TileEntity tileentity = worldIn.getTileEntity(pos); - if(tileentity instanceof TileEntityMachine) { - playerIn.displayGUIChest((TileEntityMachine)tileentity); + if(tileentity instanceof TileEntityDevice) { + playerIn.displayGUIChest((TileEntityDevice)tileentity); // playerIn.triggerAchievement(StatList.hopperStat); } return true; @@ -59,8 +59,8 @@ public abstract class BlockMachine extends BlockDirectional implements ITileEnti public void onBlockRemoved(AWorldServer worldIn, BlockPos pos, State state) { TileEntity tileentity = worldIn.getTileEntity(pos); - if(tileentity instanceof TileEntityMachine) { - InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityMachine)tileentity); + if(tileentity instanceof TileEntityDevice) { + InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityDevice)tileentity); worldIn.updateComparatorOutputLevel(pos, this); } super.onBlockRemoved(worldIn, pos, state); diff --git a/common/src/main/java/common/entity/animal/EntityHorse.java b/common/src/main/java/common/entity/animal/EntityHorse.java index b34c369..09dc59a 100755 --- a/common/src/main/java/common/entity/animal/EntityHorse.java +++ b/common/src/main/java/common/entity/animal/EntityHorse.java @@ -789,7 +789,7 @@ public class EntityHorse extends EntityAnimal implements IInvBasic if (!this.worldObj.client && (this.passenger == null || this.passenger == playerEntity) && this.isTame()) { this.horseChest.setCustomName(this.getName()); - playerEntity.displayGUIHorse(this, this.horseChest); + playerEntity.displayEntityGui(this, this.horseChest); } } diff --git a/common/src/main/java/common/entity/npc/EntityNPC.java b/common/src/main/java/common/entity/npc/EntityNPC.java index b4ab6b3..7e645b1 100755 --- a/common/src/main/java/common/entity/npc/EntityNPC.java +++ b/common/src/main/java/common/entity/npc/EntityNPC.java @@ -2052,12 +2052,6 @@ public abstract class EntityNPC extends EntityLiving { if(this.connection != null) this.connection.closeScreen(); - else if(this.client != null) { -// this.setScreenClosed(); -// this.sendQueue.addToSendQueue(new CPacketAction(CPacketAction.Action.CLOSE_CONTAINER)); // , this.openContainer.windowId)); -// this.closeScreenAndDropStack(); - this.client.closeGui(); - } else this.openContainer = this.inventoryContainer; } @@ -2169,8 +2163,6 @@ public abstract class EntityNPC extends EntityLiving { if(this.connection != null) this.connection.openEditSign(signTile); - else if(this.client != null) - this.client.displayGuiSign(signTile.getPos(), signTile.signText); } /** @@ -2197,26 +2189,18 @@ public abstract class EntityNPC extends EntityLiving { if(this.connection != null) this.connection.displayGUIChest(chestInventory); - else if(this.client != null) { - this.client.displayGUIChest(chestInventory, this.inventory); - } } - public void displayGUIHorse(EntityHorse horse, IInventory horseInventory) + public void displayEntityGui(Entity entity, IInventory inventory) { if(this.connection != null) - this.connection.displayGUIHorse(horse, horseInventory); - else if(this.client != null) - this.client.displayGuiHorse(horse, this.inventory, horseInventory); + this.connection.displayEntityGui(entity, inventory); } public void displayGui(IInteractionObject guiOwner) { if(this.connection != null) this.connection.displayGui(guiOwner); - else if(this.client != null) { - this.client.displayGui(guiOwner, this.inventory, this.worldObj); - } } /** @@ -2794,11 +2778,6 @@ public abstract class EntityNPC extends EntityLiving return this.horseJumpPower; } - public void displayTradeGui(String title) - { - this.client.displayGuiMerchant(title, this.inventory, this.worldObj); - } - // END SP SPEC diff --git a/common/src/main/java/common/inventory/ContainerEntityInventory.java b/common/src/main/java/common/inventory/ContainerEntityInventory.java new file mode 100755 index 0000000..32ba225 --- /dev/null +++ b/common/src/main/java/common/inventory/ContainerEntityInventory.java @@ -0,0 +1,132 @@ +package common.inventory; + +import common.entity.Entity; +import common.entity.animal.EntityHorse; +import common.entity.npc.EntityNPC; +import common.init.Items; +import common.item.ItemStack; + +public class ContainerEntityInventory extends Container +{ + private IInventory entityInventory; + private Entity entity; + + public ContainerEntityInventory(IInventory playerInventory, final IInventory entityInv, final Entity entity, EntityNPC player) + { + this.entityInventory = entityInv; + this.entity = entity; + int i = 3; + entityInv.openInventory(player); + int j = (i - 4) * 18; + if(this.entity instanceof EntityHorse) { + final EntityHorse horse = (EntityHorse)this.entity; + this.addSlotToContainer(new Slot(entityInv, 0, 8, 18) + { + public boolean isItemValid(ItemStack stack) + { + return super.isItemValid(stack) && stack.getItem() == Items.saddle && !this.getHasStack(); + } + }); + this.addSlotToContainer(new Slot(entityInv, 1, 8, 36) + { + public boolean isItemValid(ItemStack stack) + { + return super.isItemValid(stack) && horse.canWearArmor() && EntityHorse.isArmorItem(stack.getItem()); + } + public boolean canBeHovered() + { + return horse.canWearArmor(); + } + }); + if (horse.isChested()) + { + for (int k = 0; k < i; ++k) + { + for (int l = 0; l < 5; ++l) + { + this.addSlotToContainer(new Slot(entityInv, 2 + l + k * 5, 80 + l * 18, 18 + k * 18)); + } + } + } + } + + for (int i1 = 0; i1 < 3; ++i1) + { + for (int k1 = 0; k1 < 9; ++k1) + { + this.addSlotToContainer(new Slot(playerInventory, k1 + i1 * 9 + 9, 8 + k1 * 18, 102 + i1 * 18 + j)); + } + } + + for (int j1 = 0; j1 < 9; ++j1) + { + this.addSlotToContainer(new Slot(playerInventory, j1, 8 + j1 * 18, 160 + j)); + } + } + + public boolean canInteractWith(EntityNPC playerIn) + { + return this.entityInventory.isUseableByPlayer(playerIn) && this.entity.isEntityAlive() && this.entity.getDistanceToEntity(playerIn) < 8.0F; + } + + /** + * Take a stack from the specified inventory slot. + */ + public ItemStack transferStackInSlot(EntityNPC playerIn, int index) + { + ItemStack itemstack = null; + Slot slot = (Slot)this.inventorySlots.get(index); + + if (slot != null && slot.getHasStack()) + { + ItemStack itemstack1 = slot.getStack(); + itemstack = itemstack1.copy(); + + if (index < this.entityInventory.getSizeInventory()) + { + if (!this.mergeItemStack(itemstack1, this.entityInventory.getSizeInventory(), this.inventorySlots.size(), true)) + { + return null; + } + } + else if (this.entity instanceof EntityHorse && this.getSlot(1).isItemValid(itemstack1) && !this.getSlot(1).getHasStack()) + { + if (!this.mergeItemStack(itemstack1, 1, 2, false)) + { + return null; + } + } + else if (this.entity instanceof EntityHorse && this.getSlot(0).isItemValid(itemstack1)) + { + if (!this.mergeItemStack(itemstack1, 0, 1, false)) + { + return null; + } + } + else if (this.entity instanceof EntityHorse && (this.entityInventory.getSizeInventory() <= 2 || !this.mergeItemStack(itemstack1, 2, this.entityInventory.getSizeInventory(), false))) + { + return null; + } + + if (itemstack1.size == 0) + { + slot.putStack((ItemStack)null); + } + else + { + slot.onSlotChanged(); + } + } + + return itemstack; + } + + /** + * Called when the container is closed. + */ + public void onContainerClosed(EntityNPC playerIn) + { + super.onContainerClosed(playerIn); + this.entityInventory.closeInventory(playerIn); + } +} diff --git a/common/src/main/java/common/inventory/ContainerHorseInventory.java b/common/src/main/java/common/inventory/ContainerHorseInventory.java deleted file mode 100755 index abc7c96..0000000 --- a/common/src/main/java/common/inventory/ContainerHorseInventory.java +++ /dev/null @@ -1,129 +0,0 @@ -package common.inventory; - -import common.entity.animal.EntityHorse; -import common.entity.npc.EntityNPC; -import common.init.Items; -import common.item.ItemStack; - -public class ContainerHorseInventory extends Container -{ - private IInventory horseInventory; - private EntityHorse theHorse; - - public ContainerHorseInventory(IInventory playerInventory, final IInventory horseInventoryIn, final EntityHorse horse, EntityNPC player) - { - this.horseInventory = horseInventoryIn; - this.theHorse = horse; - int i = 3; - horseInventoryIn.openInventory(player); - int j = (i - 4) * 18; - this.addSlotToContainer(new Slot(horseInventoryIn, 0, 8, 18) - { - public boolean isItemValid(ItemStack stack) - { - return super.isItemValid(stack) && stack.getItem() == Items.saddle && !this.getHasStack(); - } - }); - this.addSlotToContainer(new Slot(horseInventoryIn, 1, 8, 36) - { - public boolean isItemValid(ItemStack stack) - { - return super.isItemValid(stack) && horse.canWearArmor() && EntityHorse.isArmorItem(stack.getItem()); - } - public boolean canBeHovered() - { - return horse.canWearArmor(); - } - }); - - if (horse.isChested()) - { - for (int k = 0; k < i; ++k) - { - for (int l = 0; l < 5; ++l) - { - this.addSlotToContainer(new Slot(horseInventoryIn, 2 + l + k * 5, 80 + l * 18, 18 + k * 18)); - } - } - } - - for (int i1 = 0; i1 < 3; ++i1) - { - for (int k1 = 0; k1 < 9; ++k1) - { - this.addSlotToContainer(new Slot(playerInventory, k1 + i1 * 9 + 9, 8 + k1 * 18, 102 + i1 * 18 + j)); - } - } - - for (int j1 = 0; j1 < 9; ++j1) - { - this.addSlotToContainer(new Slot(playerInventory, j1, 8 + j1 * 18, 160 + j)); - } - } - - public boolean canInteractWith(EntityNPC playerIn) - { - return this.horseInventory.isUseableByPlayer(playerIn) && this.theHorse.isEntityAlive() && this.theHorse.getDistanceToEntity(playerIn) < 8.0F; - } - - /** - * Take a stack from the specified inventory slot. - */ - public ItemStack transferStackInSlot(EntityNPC playerIn, int index) - { - ItemStack itemstack = null; - Slot slot = (Slot)this.inventorySlots.get(index); - - if (slot != null && slot.getHasStack()) - { - ItemStack itemstack1 = slot.getStack(); - itemstack = itemstack1.copy(); - - if (index < this.horseInventory.getSizeInventory()) - { - if (!this.mergeItemStack(itemstack1, this.horseInventory.getSizeInventory(), this.inventorySlots.size(), true)) - { - return null; - } - } - else if (this.getSlot(1).isItemValid(itemstack1) && !this.getSlot(1).getHasStack()) - { - if (!this.mergeItemStack(itemstack1, 1, 2, false)) - { - return null; - } - } - else if (this.getSlot(0).isItemValid(itemstack1)) - { - if (!this.mergeItemStack(itemstack1, 0, 1, false)) - { - return null; - } - } - else if (this.horseInventory.getSizeInventory() <= 2 || !this.mergeItemStack(itemstack1, 2, this.horseInventory.getSizeInventory(), false)) - { - return null; - } - - if (itemstack1.size == 0) - { - slot.putStack((ItemStack)null); - } - else - { - slot.onSlotChanged(); - } - } - - return itemstack; - } - - /** - * Called when the container is closed. - */ - public void onContainerClosed(EntityNPC playerIn) - { - super.onContainerClosed(playerIn); - this.horseInventory.closeInventory(playerIn); - } -} diff --git a/common/src/main/java/common/inventory/ContainerLocalMenu.java b/common/src/main/java/common/inventory/ContainerLocalMenu.java deleted file mode 100755 index 8c80f37..0000000 --- a/common/src/main/java/common/inventory/ContainerLocalMenu.java +++ /dev/null @@ -1,59 +0,0 @@ -package common.inventory; - -import java.util.Map; - -import common.collect.Maps; -import common.entity.npc.EntityNPC; -import common.tileentity.ILockableContainer; -import common.tileentity.Passcode; - -public class ContainerLocalMenu extends InventoryBasic implements ILockableContainer -{ - private String guiID; - private Map field_174895_b = Maps.newHashMap(); - - public ContainerLocalMenu(String id, String title, int slotCount) - { - super(title, slotCount); - this.guiID = id; - } - - public int getField(int id) - { - return this.field_174895_b.containsKey(Integer.valueOf(id)) ? ((Integer)this.field_174895_b.get(Integer.valueOf(id))).intValue() : 0; - } - - public void setField(int id, int value) - { - this.field_174895_b.put(Integer.valueOf(id), Integer.valueOf(value)); - } - - public int getFieldCount() - { - return this.field_174895_b.size(); - } - - public boolean isLocked() - { - return false; - } - - public void setLockCode(Passcode code) - { - } - - public Passcode getLockCode() - { - return Passcode.EMPTY_CODE; - } - - public String getGuiID() - { - return this.guiID; - } - - public Container createContainer(InventoryPlayer playerInventory, EntityNPC playerIn) - { - throw new UnsupportedOperationException(); - } -} diff --git a/common/src/main/java/common/inventory/ContainerMachine.java b/common/src/main/java/common/inventory/ContainerTile.java similarity index 77% rename from common/src/main/java/common/inventory/ContainerMachine.java rename to common/src/main/java/common/inventory/ContainerTile.java index d9c894b..ff7169a 100755 --- a/common/src/main/java/common/inventory/ContainerMachine.java +++ b/common/src/main/java/common/inventory/ContainerTile.java @@ -2,32 +2,32 @@ package common.inventory; import common.entity.npc.EntityNPC; import common.item.ItemStack; -import common.tileentity.TileEntityMachine; -import common.tileentity.TileEntityMachine.Status; +import common.tileentity.TileEntityDevice; +import common.tileentity.TileEntityDevice.Status; -public class ContainerMachine extends Container +public class ContainerTile extends Container { - private final IInventory machine; - private final TileEntityMachine tile; + private final IInventory tileInv; + private final TileEntityDevice tile; private int temperature; private Status status = Status.OFF; private final int[] resources; - public ContainerMachine(InventoryPlayer playerInv, TileEntityMachine tile, IInventory machine, EntityNPC player) + public ContainerTile(InventoryPlayer playerInv, TileEntityDevice tile, IInventory tileInv, EntityNPC player) { - this.machine = machine; + this.tileInv = tileInv; this.tile = tile; this.resources = new int[tile.getNumResources()]; - machine.openInventory(player); + tileInv.openInventory(player); int i = 71; - for (int j = 0; j < machine.getSizeInventory(); ++j) + for (int j = 0; j < tileInv.getSizeInventory(); ++j) { final int index = j; - this.addSlotToContainer(new Slot(machine, j, 8 + j * 18, 40) { + this.addSlotToContainer(new Slot(tileInv, j, 8 + j * 18, 40) { public boolean isItemValid(ItemStack stack) { - return ContainerMachine.this.tile.isItemValidForSlot(index, stack); + return ContainerTile.this.tile.isItemValidForSlot(index, stack); } }); } @@ -48,7 +48,7 @@ public class ContainerMachine extends Container public boolean canInteractWith(EntityNPC playerIn) { - return this.machine.isUseableByPlayer(playerIn); + return this.tileInv.isUseableByPlayer(playerIn); } protected boolean canTransfer(Slot slot, ItemStack stack) { @@ -65,14 +65,14 @@ public class ContainerMachine extends Container ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); - if (index < this.machine.getSizeInventory()) + if (index < this.tileInv.getSizeInventory()) { - if (!this.mergeItemStack(itemstack1, this.machine.getSizeInventory(), this.inventorySlots.size(), true)) + if (!this.mergeItemStack(itemstack1, this.tileInv.getSizeInventory(), this.inventorySlots.size(), true)) { return null; } } - else if (!this.mergeItemStack(itemstack1, 0, this.machine.getSizeInventory(), false)) + else if (!this.mergeItemStack(itemstack1, 0, this.tileInv.getSizeInventory(), false)) { return null; } @@ -93,7 +93,7 @@ public class ContainerMachine extends Container public void onContainerClosed(EntityNPC playerIn) { super.onContainerClosed(playerIn); - this.machine.closeInventory(playerIn); + this.tileInv.closeInventory(playerIn); } public void onCraftGuiOpened(ICrafting listener) diff --git a/common/src/main/java/common/network/IClientPlayer.java b/common/src/main/java/common/network/IClientPlayer.java index 8fb9aec..eb4c55c 100644 --- a/common/src/main/java/common/network/IClientPlayer.java +++ b/common/src/main/java/common/network/IClientPlayer.java @@ -1,9 +1,6 @@ package common.network; import common.entity.Entity; -import common.entity.animal.EntityHorse; -import common.inventory.IInventory; -import common.inventory.InventoryPlayer; import common.model.ParticleType; import common.packet.SPacketEntity; import common.packet.SPacketEntityTeleport; @@ -68,9 +65,6 @@ import common.packet.SPacketTrades; import common.packet.SPacketUpdateHealth; import common.packet.SPacketWorld; import common.sound.Sound; -import common.tileentity.IInteractionObject; -import common.util.BlockPos; -import common.world.World; public interface IClientPlayer extends NetHandler { void playSound(Sound sound); @@ -148,11 +142,4 @@ public interface IClientPlayer extends NetHandler { void handleWorld(SPacketWorld packet); void handleDimName(SPacketDimensionName packet); void handleForm(SPacketDisplayForm packet); - - void displayGUIChest(IInventory chestInventory, InventoryPlayer inventory); - void displayGui(IInteractionObject guiOwner, InventoryPlayer inventory, World world); - void displayGuiHorse(EntityHorse horse, InventoryPlayer inventory, IInventory horseInventory); - void displayGuiMerchant(String title, InventoryPlayer inventory, World world); - void displayGuiSign(BlockPos pos, String[] text); - void closeGui(); } \ No newline at end of file diff --git a/common/src/main/java/common/network/IPlayer.java b/common/src/main/java/common/network/IPlayer.java index 7637c4a..41d069e 100644 --- a/common/src/main/java/common/network/IPlayer.java +++ b/common/src/main/java/common/network/IPlayer.java @@ -3,7 +3,6 @@ package common.network; import java.util.List; import common.entity.Entity; -import common.entity.animal.EntityHorse; import common.entity.npc.EntityNPC; import common.entity.types.EntityLiving; import common.init.SoundEvent; @@ -84,7 +83,7 @@ public interface IPlayer extends NetHandler { void openEditSign(TileEntitySign signTile); void displayGui(IInteractionObject guiOwner); void displayGUIChest(IInventory chestInventory); - void displayGUIHorse(EntityHorse horse, IInventory horseInventory); + void displayEntityGui(Entity entity, IInventory inventory); void closeScreen(); void onItemUseFinish(); void onNewEffect(PotionEffect id); diff --git a/common/src/main/java/common/packet/SPacketOpenWindow.java b/common/src/main/java/common/packet/SPacketOpenWindow.java index c66e944..1ec413e 100755 --- a/common/src/main/java/common/packet/SPacketOpenWindow.java +++ b/common/src/main/java/common/packet/SPacketOpenWindow.java @@ -63,11 +63,11 @@ public class SPacketOpenWindow implements Packet this.windowTitle = buf.readString(256); this.slotCount = buf.readUnsignedByte(); - if (this.inventoryType.equals("EntityHorse")) + if (this.inventoryType.equals("entity")) { this.entityId = buf.readInt(); } - else if(this.inventoryType.startsWith("machine_")) { + else if(this.inventoryType.equals("tile")) { this.tilePos = buf.readBlockPos(); } } @@ -82,11 +82,11 @@ public class SPacketOpenWindow implements Packet buf.writeString(this.windowTitle); buf.writeByte(this.slotCount); - if (this.inventoryType.equals("EntityHorse")) + if (this.inventoryType.equals("entity")) { buf.writeInt(this.entityId); } - else if(this.inventoryType.startsWith("machine_")) { + else if(this.inventoryType.equals("tile")) { buf.writeBlockPos(this.tilePos); } } @@ -120,9 +120,4 @@ public class SPacketOpenWindow implements Packet { return this.tilePos; } - - public boolean hasSlots() - { - return this.slotCount > 0 || this.inventoryType.startsWith("machine_"); - } } diff --git a/common/src/main/java/common/tileentity/TileEntityMachine.java b/common/src/main/java/common/tileentity/TileEntityDevice.java similarity index 92% rename from common/src/main/java/common/tileentity/TileEntityMachine.java rename to common/src/main/java/common/tileentity/TileEntityDevice.java index 0878e42..3b48d6b 100755 --- a/common/src/main/java/common/tileentity/TileEntityMachine.java +++ b/common/src/main/java/common/tileentity/TileEntityDevice.java @@ -4,7 +4,7 @@ import common.collect.Lists; import common.color.TextColor; import common.entity.npc.EntityNPC; import common.inventory.Container; -import common.inventory.ContainerMachine; +import common.inventory.ContainerTile; import common.inventory.InventoryPlayer; import common.item.ItemStack; import common.network.Packet; @@ -14,7 +14,7 @@ import common.tags.TagObject; import java.util.List; import common.util.ExtMath; -public abstract class TileEntityMachine extends TileEntityLockable implements IHopper, ITickable { +public abstract class TileEntityDevice extends TileEntityLockable implements IHopper, ITickable { public static enum Status { OFF(TextColor.DGRAY, "Inaktiv"), COOLING(TextColor.YELLOW, "Abkühlen ..."), @@ -34,11 +34,10 @@ public abstract class TileEntityMachine extends TileEntityLockable implements IH protected final ItemStack[] inventory; protected final MachineResource[] resources; protected final Random rand = new Random(); -// protected boolean isCreative; protected int temperature; protected Status status = Status.OFF; - protected TileEntityMachine(int slots, MachineResource ... resources) { + protected TileEntityDevice(int slots, MachineResource ... resources) { this.inventory = new ItemStack[slots]; this.resources = resources; } @@ -51,14 +50,6 @@ public abstract class TileEntityMachine extends TileEntityLockable implements IH public MachineResource getResource(int slot) { return this.resources[slot]; } - -// public void setCreative(boolean creative) { -// this.isCreative = creative; -// } -// -// public boolean isCreative() { -// return this.isCreative; -// } public int getNumResources() { return this.resources.length; @@ -102,7 +93,6 @@ public abstract class TileEntityMachine extends TileEntityLockable implements IH this.resources[i].readFromNbt(nbttaglist.get(i)); } -// this.isCreative = compound.getBoolean("Creative"); this.temperature = compound.getInt("Temperature"); this.status = Status.values()[(int)compound.getByte("Status") % Status.values().length]; } @@ -129,16 +119,10 @@ public abstract class TileEntityMachine extends TileEntityLockable implements IH } compound.setList("Resources", nbttaglist); -// compound.setBoolean("Creative", this.isCreative); compound.setInt("Temperature", this.temperature); compound.setByte("Status", (byte)this.status.ordinal()); } -// public void markDirty() -// { -// super.markDirty(); -// } - public int getSizeInventory() { return this.inventory.length; } @@ -305,7 +289,7 @@ public abstract class TileEntityMachine extends TileEntityLockable implements IH } public Container createContainer(InventoryPlayer playerInventory, EntityNPC playerIn) { - return new ContainerMachine(playerInventory, this, this, playerIn); + return new ContainerTile(playerInventory, this, this, playerIn); } public int getField(int id) { diff --git a/common/src/main/java/common/tileentity/TileEntityTianReactor.java b/common/src/main/java/common/tileentity/TileEntityTianReactor.java index b2d4939..5dd7416 100755 --- a/common/src/main/java/common/tileentity/TileEntityTianReactor.java +++ b/common/src/main/java/common/tileentity/TileEntityTianReactor.java @@ -6,7 +6,7 @@ import common.init.Items; import common.item.ItemStack; import common.tileentity.MachineResource.Type; -public class TileEntityTianReactor extends TileEntityMachine { +public class TileEntityTianReactor extends TileEntityDevice { public TileEntityTianReactor() { super(2, new MachineResource(Type.OUTPUT, "output.energy", 1024, 0, 0)); } diff --git a/server/src/main/java/server/network/Player.java b/server/src/main/java/server/network/Player.java index 85a70ff..7ddfdd0 100755 --- a/server/src/main/java/server/network/Player.java +++ b/server/src/main/java/server/network/Player.java @@ -34,7 +34,7 @@ import common.init.SoundEvent; import common.init.UniverseRegistry; import common.inventory.Container; import common.inventory.ContainerChest; -import common.inventory.ContainerHorseInventory; +import common.inventory.ContainerEntityInventory; import common.inventory.ContainerMerchant; import common.inventory.ICrafting; import common.inventory.IInventory; @@ -104,7 +104,7 @@ import common.tags.TagObject; import common.tileentity.IInteractionObject; import common.tileentity.ILockableContainer; import common.tileentity.TileEntity; -import common.tileentity.TileEntityMachine; +import common.tileentity.TileEntityDevice; import common.tileentity.TileEntitySign; import common.util.BlockPos; import common.util.BoundingBox; @@ -699,10 +699,10 @@ public class Player extends User implements ICrafting, Executor, IPlayer this.getNextWindowId(); - if (chestInventory instanceof TileEntityMachine) + if (chestInventory instanceof TileEntityDevice) { - this.sendPacket(new SPacketOpenWindow(this.currentWindowId, "machine_" + ((IInteractionObject)chestInventory).getGuiID(), chestInventory.getCommandName(), chestInventory.getSizeInventory(), - ((TileEntityMachine)chestInventory).getPos())); + this.sendPacket(new SPacketOpenWindow(this.currentWindowId, "tile", chestInventory.getCommandName(), chestInventory.getSizeInventory(), + ((TileEntityDevice)chestInventory).getPos())); this.entity.openContainer = ((IInteractionObject)chestInventory).createContainer(this.entity.inventory, this.entity); } else if (chestInventory instanceof IInteractionObject) @@ -720,7 +720,7 @@ public class Player extends User implements ICrafting, Executor, IPlayer this.entity.openContainer.onCraftGuiOpened(this); } - public void displayGUIHorse(EntityHorse horse, IInventory horseInventory) + public void displayEntityGui(Entity entity, IInventory inventory) { if (this.entity.openContainer != this.entity.inventoryContainer) { @@ -728,8 +728,8 @@ public class Player extends User implements ICrafting, Executor, IPlayer } this.getNextWindowId(); - this.sendPacket(new SPacketOpenWindow(this.currentWindowId, "EntityHorse", horseInventory.getCommandName(), horseInventory.getSizeInventory(), horse.getId())); - this.entity.openContainer = new ContainerHorseInventory(this.entity.inventory, horseInventory, horse, this.entity); + this.sendPacket(new SPacketOpenWindow(this.currentWindowId, "entity", inventory.getCommandName(), inventory.getSizeInventory(), entity.getId())); + this.entity.openContainer = new ContainerEntityInventory(this.entity.inventory, inventory, entity, this.entity); this.entity.openContainer.windowId = this.currentWindowId; this.entity.openContainer.onCraftGuiOpened(this); }