make guis more generic

This commit is contained in:
Sen 2025-05-31 18:38:53 +02:00
parent 374e0c4617
commit 5534531416
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
22 changed files with 334 additions and 504 deletions

View file

@ -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)) if (this.gm != null && this.gm.player != null && (!this.gm.player.isEntityAlive() || this.gm.player.dead))
{ {
this.gm.player.closeScreen(); this.gm.displayGuiScreen(null);
} }
} }

View file

@ -5,7 +5,6 @@ import common.enchantment.Enchantment;
import common.inventory.ContainerEnchantment; import common.inventory.ContainerEnchantment;
import common.inventory.InventoryPlayer; import common.inventory.InventoryPlayer;
import common.rng.Random; import common.rng.Random;
import common.tileentity.IWorldNameable;
import common.world.World; import common.world.World;
public class GuiEnchant extends GuiContainer public class GuiEnchant extends GuiContainer
@ -19,7 +18,7 @@ public class GuiEnchant extends GuiContainer
private final Random nameRand = new Random(); private final Random nameRand = new Random();
private final Random random = new Random(); private final Random random = new Random();
private final ContainerEnchantment container; private final ContainerEnchantment container;
private final IWorldNameable table; private final String title;
// public int field_147073_u; // public int field_147073_u;
// public float field_147071_v; // public float field_147071_v;
@ -30,12 +29,12 @@ public class GuiEnchant extends GuiContainer
// public float field_147076_A; // public float field_147076_A;
// ItemStack field_147077_B; // 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)); super(new ContainerEnchantment(inventory, worldIn));
this.playerInventory = inventory; this.playerInventory = inventory;
this.container = (ContainerEnchantment)this.inventorySlots; this.container = (ContainerEnchantment)this.inventorySlots;
this.table = table; this.title = title;
} }
/** /**
@ -43,7 +42,7 @@ public class GuiEnchant extends GuiContainer
*/ */
public void drawGuiContainerForegroundLayer() 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); this.drawString(this.playerInventory.getCommandName(), 8, this.ySize - 96 + 2);
} }

View file

@ -1,45 +1,26 @@
package client.gui.container; package client.gui.container;
import client.Client; import client.Client;
import common.entity.animal.EntityHorse; import common.entity.Entity;
import common.inventory.ContainerHorseInventory; import common.inventory.ContainerEntityInventory;
import common.inventory.IInventory; 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 playerInventory;
private IInventory entityInventory;
/** The horse inventory bound to this GUI. */ public GuiEntity(IInventory playerInv, IInventory entityInv, Entity entity)
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)
{ {
super(new ContainerHorseInventory(playerInv, horseInv, horse, Client.CLIENT.player)); super(new ContainerEntityInventory(playerInv, entityInv, entity, Client.CLIENT.player));
this.playerInventory = playerInv; this.playerInventory = playerInv;
this.horseInventory = horseInv; this.entityInventory = entityInv;
// this.horseEntity = horse;
// this.allowUserInput = false;
} }
/**
* Draw the foreground layer for the GuiContainer (everything in front of the items). Args : mouseX, mouseY
*/
public void drawGuiContainerForegroundLayer() 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); this.drawString(this.playerInventory.getCommandName(), 8, this.ySize - 96 + 2);
} }

View file

@ -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);
// }
}

View file

@ -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);
}
}

View file

@ -15,8 +15,8 @@ import client.gui.container.GuiDispenser;
import client.gui.container.GuiEnchant; import client.gui.container.GuiEnchant;
import client.gui.container.GuiFurnace; import client.gui.container.GuiFurnace;
import client.gui.container.GuiHopper; import client.gui.container.GuiHopper;
import client.gui.container.GuiHorse; import client.gui.container.GuiEntity;
import client.gui.container.GuiMachine; import client.gui.container.GuiTile;
import client.gui.container.GuiMerchant; import client.gui.container.GuiMerchant;
import client.gui.container.GuiRepair; import client.gui.container.GuiRepair;
import client.gui.ingame.GuiSign; import client.gui.ingame.GuiSign;
@ -35,7 +35,6 @@ import common.block.tech.BlockWorkbench;
import common.dimension.Dimension; import common.dimension.Dimension;
import common.entity.DataWatcher; import common.entity.DataWatcher;
import common.entity.Entity; import common.entity.Entity;
import common.entity.animal.EntityHorse;
import common.entity.effect.EntityLightning; import common.entity.effect.EntityLightning;
import common.entity.item.EntityBoat; import common.entity.item.EntityBoat;
import common.entity.item.EntityXp; import common.entity.item.EntityXp;
@ -49,8 +48,6 @@ import common.init.ItemRegistry;
import common.init.SoundEvent; import common.init.SoundEvent;
import common.inventory.AnimalChest; import common.inventory.AnimalChest;
import common.inventory.Container; import common.inventory.Container;
import common.inventory.ContainerLocalMenu;
import common.inventory.IInventory;
import common.inventory.InventoryBasic; import common.inventory.InventoryBasic;
import common.inventory.InventoryPlayer; import common.inventory.InventoryPlayer;
import common.item.ItemStack; import common.item.ItemStack;
@ -128,11 +125,9 @@ import common.packet.SPacketWorld;
import common.potion.PotionEffect; import common.potion.PotionEffect;
import common.rng.Random; import common.rng.Random;
import common.sound.Sound; import common.sound.Sound;
import common.tileentity.IInteractionObject;
import common.tileentity.TileEntity; import common.tileentity.TileEntity;
import common.tileentity.TileEntityMachine; import common.tileentity.TileEntityDevice;
import common.tileentity.TileEntitySign; import common.tileentity.TileEntitySign;
import common.util.BlockPos;
import common.village.MerchantRecipeList; import common.village.MerchantRecipeList;
import common.world.Explosion; import common.world.Explosion;
import common.world.Weather; import common.world.Weather;
@ -188,10 +183,6 @@ public class ClientPlayer implements IClientPlayer
public final void updatePlayerMoveState() { public final void updatePlayerMoveState() {
this.gm.updatePlayerMoveState(); this.gm.updatePlayerMoveState();
} }
public final void closeGui() {
this.gm.displayGuiScreen(null);
}
public final NetConnection getConnection() { public final NetConnection getConnection() {
return this.connection; 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, * 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 * 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); NetHandler.checkThread(packet, this, this.gm, this.world);
EntityNPC entityplayersp = this.gm.player; 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())); this.gm.displayGuiScreen(new GuiChest(player.inventory, new InventoryBasic(title, slots)));
entityplayersp.openContainer.windowId = packetIn.getWindowId();
} }
else if ("trade".equals(packetIn.getGuiId())) else if ("enchanting_table".equals(id))
{ {
entityplayersp.displayTradeGui(packetIn.getWindowTitle()); this.gm.displayGuiScreen(new GuiEnchant(player.inventory, player.worldObj, title));
entityplayersp.openContainer.windowId = packetIn.getWindowId();
} }
else if ("EntityHorse".equals(packetIn.getGuiId())) else if ("anvil".equals(id))
{ {
Entity entity = this.world.getEntityByID(packetIn.getEntityId()); this.gm.displayGuiScreen(new GuiRepair(player.inventory, player.worldObj));
if (entity instanceof EntityHorse)
{
entityplayersp.displayGUIHorse((EntityHorse)entity, new AnimalChest(packetIn.getWindowTitle(), true, packetIn.getSlotCount()));
entityplayersp.openContainer.windowId = packetIn.getWindowId();
}
} }
else if (!packetIn.hasSlots()) else if ("chest".equals(id))
{ {
entityplayersp.displayGui(new DummyContainer(packetIn.getGuiId(), packetIn.getWindowTitle())); this.gm.displayGuiScreen(new GuiChest(player.inventory, local));
entityplayersp.openContainer.windowId = packetIn.getWindowId(); }
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 else
{ {
ContainerLocalMenu containerlocalmenu = new ContainerLocalMenu(packetIn.getGuiId(), packetIn.getWindowTitle(), packetIn.getSlotCount()); Block block = BlockRegistry.getRegisteredBlock(id);
if (packetIn.getGuiId().startsWith("machine_")) if(block instanceof BlockWorkbench) {
{ this.gm.displayGuiScreen(new GuiCrafting(player.inventory, player.worldObj, (BlockWorkbench)block));
TileEntity machine = this.world.getTileEntity(packetIn.getTilePos()); }
if(machine instanceof TileEntityMachine) else {
this.gm.displayGuiScreen(new GuiMachine(this.gm.player.inventory, containerlocalmenu, (TileEntityMachine)machine)); this.gm.displayGuiScreen(new GuiChest(player.inventory, local));
} }
else {
entityplayersp.displayGUIChest(containerlocalmenu);
}
entityplayersp.openContainer.windowId = packetIn.getWindowId();
} }
player.openContainer.windowId = packet.getWindowId();
} }
/** /**
* Handles pickin up an ItemStack or dropping one in your inventory or an open container * Handles pickin up an ItemStack or dropping one in your inventory or an open container
*/ */
public void handleSetSlot(SPacketSetSlot packetIn) public void handleSetSlot(SPacketSetSlot packetIn)
@ -1262,7 +1279,7 @@ public class ClientPlayer implements IClientPlayer
tileentity.setPos(packetIn.getSignPosition()); 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) { public void handleForm(SPacketDisplayForm packet) {
@ -1959,66 +1976,4 @@ public class ClientPlayer implements IClientPlayer
this.world.dimension.setFullName(packetIn.getFullName()); this.world.dimension.setFullName(packetIn.getFullName());
this.world.dimension.setCustomName(packetIn.getCustomName()); 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));
}
} }

View file

@ -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();
}
}

View file

@ -5,11 +5,8 @@ import client.util.DummyController;
import client.world.WorldClient; import client.world.WorldClient;
import common.dimension.Space; import common.dimension.Space;
import common.entity.Entity; import common.entity.Entity;
import common.entity.animal.EntityHorse;
import common.entity.npc.EntityCpu; import common.entity.npc.EntityCpu;
import common.init.EntityRegistry; import common.init.EntityRegistry;
import common.inventory.IInventory;
import common.inventory.InventoryPlayer;
import common.model.ParticleType; import common.model.ParticleType;
import common.network.Packet; import common.network.Packet;
import common.packet.SPacketEntity; import common.packet.SPacketEntity;
@ -77,9 +74,6 @@ import common.packet.SPacketWorld;
import common.potion.Potion; import common.potion.Potion;
import common.potion.PotionEffect; import common.potion.PotionEffect;
import common.sound.Sound; import common.sound.Sound;
import common.tileentity.IInteractionObject;
import common.util.BlockPos;
import common.world.World;
public class DummyPlayer extends ClientPlayer { public class DummyPlayer extends ClientPlayer {
public DummyPlayer(Client gm) { public DummyPlayer(Client gm) {
@ -102,6 +96,7 @@ public class DummyPlayer extends ClientPlayer {
world.setTimeFactor(this.gm.timeFactor = 1); world.setTimeFactor(this.gm.timeFactor = 1);
this.gm.dayCycle = true; this.gm.dayCycle = true;
} }
public void cleanup() { public void cleanup() {
} }
@ -112,26 +107,12 @@ public class DummyPlayer extends ClientPlayer {
public void emitParticleAtEntity(Entity entityIn, ParticleType particleTypes) { 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 onDisconnect(String reason) {
} }
public void addToSendQueue(Packet packet) { public void addToSendQueue(Packet packet) {
} }
public void handleJoinGame(SPacketJoinGame packetIn) { public void handleJoinGame(SPacketJoinGame packetIn) {
} }

View file

@ -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<Integer, Integer> fields = Maps.<Integer, Integer>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();
}
}

View file

@ -11,7 +11,7 @@ import common.inventory.InventoryHelper;
import common.item.CheatTab; import common.item.CheatTab;
import common.properties.IProperty; import common.properties.IProperty;
import common.tileentity.TileEntity; import common.tileentity.TileEntity;
import common.tileentity.TileEntityMachine; import common.tileentity.TileEntityDevice;
import common.util.BlockPos; import common.util.BlockPos;
import common.util.Facing; import common.util.Facing;
import common.world.State; import common.world.State;
@ -37,8 +37,8 @@ public abstract class BlockMachine extends BlockDirectional implements ITileEnti
if(worldIn.client) if(worldIn.client)
return true; return true;
TileEntity tileentity = worldIn.getTileEntity(pos); TileEntity tileentity = worldIn.getTileEntity(pos);
if(tileentity instanceof TileEntityMachine) { if(tileentity instanceof TileEntityDevice) {
playerIn.displayGUIChest((TileEntityMachine)tileentity); playerIn.displayGUIChest((TileEntityDevice)tileentity);
// playerIn.triggerAchievement(StatList.hopperStat); // playerIn.triggerAchievement(StatList.hopperStat);
} }
return true; return true;
@ -59,8 +59,8 @@ public abstract class BlockMachine extends BlockDirectional implements ITileEnti
public void onBlockRemoved(AWorldServer worldIn, BlockPos pos, State state) { public void onBlockRemoved(AWorldServer worldIn, BlockPos pos, State state) {
TileEntity tileentity = worldIn.getTileEntity(pos); TileEntity tileentity = worldIn.getTileEntity(pos);
if(tileentity instanceof TileEntityMachine) { if(tileentity instanceof TileEntityDevice) {
InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityMachine)tileentity); InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityDevice)tileentity);
worldIn.updateComparatorOutputLevel(pos, this); worldIn.updateComparatorOutputLevel(pos, this);
} }
super.onBlockRemoved(worldIn, pos, state); super.onBlockRemoved(worldIn, pos, state);

View file

@ -789,7 +789,7 @@ public class EntityHorse extends EntityAnimal implements IInvBasic
if (!this.worldObj.client && (this.passenger == null || this.passenger == playerEntity) && this.isTame()) if (!this.worldObj.client && (this.passenger == null || this.passenger == playerEntity) && this.isTame())
{ {
this.horseChest.setCustomName(this.getName()); this.horseChest.setCustomName(this.getName());
playerEntity.displayGUIHorse(this, this.horseChest); playerEntity.displayEntityGui(this, this.horseChest);
} }
} }

View file

@ -2052,12 +2052,6 @@ public abstract class EntityNPC extends EntityLiving
{ {
if(this.connection != null) if(this.connection != null)
this.connection.closeScreen(); 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 else
this.openContainer = this.inventoryContainer; this.openContainer = this.inventoryContainer;
} }
@ -2169,8 +2163,6 @@ public abstract class EntityNPC extends EntityLiving
{ {
if(this.connection != null) if(this.connection != null)
this.connection.openEditSign(signTile); 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) if(this.connection != null)
this.connection.displayGUIChest(chestInventory); 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) if(this.connection != null)
this.connection.displayGUIHorse(horse, horseInventory); this.connection.displayEntityGui(entity, inventory);
else if(this.client != null)
this.client.displayGuiHorse(horse, this.inventory, horseInventory);
} }
public void displayGui(IInteractionObject guiOwner) public void displayGui(IInteractionObject guiOwner)
{ {
if(this.connection != null) if(this.connection != null)
this.connection.displayGui(guiOwner); 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; return this.horseJumpPower;
} }
public void displayTradeGui(String title)
{
this.client.displayGuiMerchant(title, this.inventory, this.worldObj);
}
// END SP SPEC // END SP SPEC

View file

@ -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);
}
}

View file

@ -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);
}
}

View file

@ -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<Integer, Integer> field_174895_b = Maps.<Integer, Integer>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();
}
}

View file

@ -2,32 +2,32 @@ package common.inventory;
import common.entity.npc.EntityNPC; import common.entity.npc.EntityNPC;
import common.item.ItemStack; import common.item.ItemStack;
import common.tileentity.TileEntityMachine; import common.tileentity.TileEntityDevice;
import common.tileentity.TileEntityMachine.Status; import common.tileentity.TileEntityDevice.Status;
public class ContainerMachine extends Container public class ContainerTile extends Container
{ {
private final IInventory machine; private final IInventory tileInv;
private final TileEntityMachine tile; private final TileEntityDevice tile;
private int temperature; private int temperature;
private Status status = Status.OFF; private Status status = Status.OFF;
private final int[] resources; 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.tile = tile;
this.resources = new int[tile.getNumResources()]; this.resources = new int[tile.getNumResources()];
machine.openInventory(player); tileInv.openInventory(player);
int i = 71; int i = 71;
for (int j = 0; j < machine.getSizeInventory(); ++j) for (int j = 0; j < tileInv.getSizeInventory(); ++j)
{ {
final int index = 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) 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) public boolean canInteractWith(EntityNPC playerIn)
{ {
return this.machine.isUseableByPlayer(playerIn); return this.tileInv.isUseableByPlayer(playerIn);
} }
protected boolean canTransfer(Slot slot, ItemStack stack) { protected boolean canTransfer(Slot slot, ItemStack stack) {
@ -65,14 +65,14 @@ public class ContainerMachine extends Container
ItemStack itemstack1 = slot.getStack(); ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy(); 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; return null;
} }
} }
else if (!this.mergeItemStack(itemstack1, 0, this.machine.getSizeInventory(), false)) else if (!this.mergeItemStack(itemstack1, 0, this.tileInv.getSizeInventory(), false))
{ {
return null; return null;
} }
@ -93,7 +93,7 @@ public class ContainerMachine extends Container
public void onContainerClosed(EntityNPC playerIn) public void onContainerClosed(EntityNPC playerIn)
{ {
super.onContainerClosed(playerIn); super.onContainerClosed(playerIn);
this.machine.closeInventory(playerIn); this.tileInv.closeInventory(playerIn);
} }
public void onCraftGuiOpened(ICrafting listener) public void onCraftGuiOpened(ICrafting listener)

View file

@ -1,9 +1,6 @@
package common.network; package common.network;
import common.entity.Entity; import common.entity.Entity;
import common.entity.animal.EntityHorse;
import common.inventory.IInventory;
import common.inventory.InventoryPlayer;
import common.model.ParticleType; import common.model.ParticleType;
import common.packet.SPacketEntity; import common.packet.SPacketEntity;
import common.packet.SPacketEntityTeleport; import common.packet.SPacketEntityTeleport;
@ -68,9 +65,6 @@ import common.packet.SPacketTrades;
import common.packet.SPacketUpdateHealth; import common.packet.SPacketUpdateHealth;
import common.packet.SPacketWorld; import common.packet.SPacketWorld;
import common.sound.Sound; import common.sound.Sound;
import common.tileentity.IInteractionObject;
import common.util.BlockPos;
import common.world.World;
public interface IClientPlayer extends NetHandler { public interface IClientPlayer extends NetHandler {
void playSound(Sound sound); void playSound(Sound sound);
@ -148,11 +142,4 @@ public interface IClientPlayer extends NetHandler {
void handleWorld(SPacketWorld packet); void handleWorld(SPacketWorld packet);
void handleDimName(SPacketDimensionName packet); void handleDimName(SPacketDimensionName packet);
void handleForm(SPacketDisplayForm 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();
} }

View file

@ -3,7 +3,6 @@ package common.network;
import java.util.List; import java.util.List;
import common.entity.Entity; import common.entity.Entity;
import common.entity.animal.EntityHorse;
import common.entity.npc.EntityNPC; import common.entity.npc.EntityNPC;
import common.entity.types.EntityLiving; import common.entity.types.EntityLiving;
import common.init.SoundEvent; import common.init.SoundEvent;
@ -84,7 +83,7 @@ public interface IPlayer extends NetHandler {
void openEditSign(TileEntitySign signTile); void openEditSign(TileEntitySign signTile);
void displayGui(IInteractionObject guiOwner); void displayGui(IInteractionObject guiOwner);
void displayGUIChest(IInventory chestInventory); void displayGUIChest(IInventory chestInventory);
void displayGUIHorse(EntityHorse horse, IInventory horseInventory); void displayEntityGui(Entity entity, IInventory inventory);
void closeScreen(); void closeScreen();
void onItemUseFinish(); void onItemUseFinish();
void onNewEffect(PotionEffect id); void onNewEffect(PotionEffect id);

View file

@ -63,11 +63,11 @@ public class SPacketOpenWindow implements Packet<IClientPlayer>
this.windowTitle = buf.readString(256); this.windowTitle = buf.readString(256);
this.slotCount = buf.readUnsignedByte(); this.slotCount = buf.readUnsignedByte();
if (this.inventoryType.equals("EntityHorse")) if (this.inventoryType.equals("entity"))
{ {
this.entityId = buf.readInt(); this.entityId = buf.readInt();
} }
else if(this.inventoryType.startsWith("machine_")) { else if(this.inventoryType.equals("tile")) {
this.tilePos = buf.readBlockPos(); this.tilePos = buf.readBlockPos();
} }
} }
@ -82,11 +82,11 @@ public class SPacketOpenWindow implements Packet<IClientPlayer>
buf.writeString(this.windowTitle); buf.writeString(this.windowTitle);
buf.writeByte(this.slotCount); buf.writeByte(this.slotCount);
if (this.inventoryType.equals("EntityHorse")) if (this.inventoryType.equals("entity"))
{ {
buf.writeInt(this.entityId); buf.writeInt(this.entityId);
} }
else if(this.inventoryType.startsWith("machine_")) { else if(this.inventoryType.equals("tile")) {
buf.writeBlockPos(this.tilePos); buf.writeBlockPos(this.tilePos);
} }
} }
@ -120,9 +120,4 @@ public class SPacketOpenWindow implements Packet<IClientPlayer>
{ {
return this.tilePos; return this.tilePos;
} }
public boolean hasSlots()
{
return this.slotCount > 0 || this.inventoryType.startsWith("machine_");
}
} }

View file

@ -4,7 +4,7 @@ import common.collect.Lists;
import common.color.TextColor; import common.color.TextColor;
import common.entity.npc.EntityNPC; import common.entity.npc.EntityNPC;
import common.inventory.Container; import common.inventory.Container;
import common.inventory.ContainerMachine; import common.inventory.ContainerTile;
import common.inventory.InventoryPlayer; import common.inventory.InventoryPlayer;
import common.item.ItemStack; import common.item.ItemStack;
import common.network.Packet; import common.network.Packet;
@ -14,7 +14,7 @@ import common.tags.TagObject;
import java.util.List; import java.util.List;
import common.util.ExtMath; 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 { public static enum Status {
OFF(TextColor.DGRAY, "Inaktiv"), OFF(TextColor.DGRAY, "Inaktiv"),
COOLING(TextColor.YELLOW, "Abkühlen ..."), COOLING(TextColor.YELLOW, "Abkühlen ..."),
@ -34,11 +34,10 @@ public abstract class TileEntityMachine extends TileEntityLockable implements IH
protected final ItemStack[] inventory; protected final ItemStack[] inventory;
protected final MachineResource[] resources; protected final MachineResource[] resources;
protected final Random rand = new Random(); protected final Random rand = new Random();
// protected boolean isCreative;
protected int temperature; protected int temperature;
protected Status status = Status.OFF; protected Status status = Status.OFF;
protected TileEntityMachine(int slots, MachineResource ... resources) { protected TileEntityDevice(int slots, MachineResource ... resources) {
this.inventory = new ItemStack[slots]; this.inventory = new ItemStack[slots];
this.resources = resources; this.resources = resources;
} }
@ -51,14 +50,6 @@ public abstract class TileEntityMachine extends TileEntityLockable implements IH
public MachineResource getResource(int slot) { public MachineResource getResource(int slot) {
return this.resources[slot]; return this.resources[slot];
} }
// public void setCreative(boolean creative) {
// this.isCreative = creative;
// }
//
// public boolean isCreative() {
// return this.isCreative;
// }
public int getNumResources() { public int getNumResources() {
return this.resources.length; return this.resources.length;
@ -102,7 +93,6 @@ public abstract class TileEntityMachine extends TileEntityLockable implements IH
this.resources[i].readFromNbt(nbttaglist.get(i)); this.resources[i].readFromNbt(nbttaglist.get(i));
} }
// this.isCreative = compound.getBoolean("Creative");
this.temperature = compound.getInt("Temperature"); this.temperature = compound.getInt("Temperature");
this.status = Status.values()[(int)compound.getByte("Status") % Status.values().length]; 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.setList("Resources", nbttaglist);
// compound.setBoolean("Creative", this.isCreative);
compound.setInt("Temperature", this.temperature); compound.setInt("Temperature", this.temperature);
compound.setByte("Status", (byte)this.status.ordinal()); compound.setByte("Status", (byte)this.status.ordinal());
} }
// public void markDirty()
// {
// super.markDirty();
// }
public int getSizeInventory() { public int getSizeInventory() {
return this.inventory.length; return this.inventory.length;
} }
@ -305,7 +289,7 @@ public abstract class TileEntityMachine extends TileEntityLockable implements IH
} }
public Container createContainer(InventoryPlayer playerInventory, EntityNPC playerIn) { 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) { public int getField(int id) {

View file

@ -6,7 +6,7 @@ import common.init.Items;
import common.item.ItemStack; import common.item.ItemStack;
import common.tileentity.MachineResource.Type; import common.tileentity.MachineResource.Type;
public class TileEntityTianReactor extends TileEntityMachine { public class TileEntityTianReactor extends TileEntityDevice {
public TileEntityTianReactor() { public TileEntityTianReactor() {
super(2, new MachineResource(Type.OUTPUT, "output.energy", 1024, 0, 0)); super(2, new MachineResource(Type.OUTPUT, "output.energy", 1024, 0, 0));
} }

View file

@ -34,7 +34,7 @@ import common.init.SoundEvent;
import common.init.UniverseRegistry; import common.init.UniverseRegistry;
import common.inventory.Container; import common.inventory.Container;
import common.inventory.ContainerChest; import common.inventory.ContainerChest;
import common.inventory.ContainerHorseInventory; import common.inventory.ContainerEntityInventory;
import common.inventory.ContainerMerchant; import common.inventory.ContainerMerchant;
import common.inventory.ICrafting; import common.inventory.ICrafting;
import common.inventory.IInventory; import common.inventory.IInventory;
@ -104,7 +104,7 @@ import common.tags.TagObject;
import common.tileentity.IInteractionObject; import common.tileentity.IInteractionObject;
import common.tileentity.ILockableContainer; import common.tileentity.ILockableContainer;
import common.tileentity.TileEntity; import common.tileentity.TileEntity;
import common.tileentity.TileEntityMachine; import common.tileentity.TileEntityDevice;
import common.tileentity.TileEntitySign; import common.tileentity.TileEntitySign;
import common.util.BlockPos; import common.util.BlockPos;
import common.util.BoundingBox; import common.util.BoundingBox;
@ -699,10 +699,10 @@ public class Player extends User implements ICrafting, Executor, IPlayer
this.getNextWindowId(); this.getNextWindowId();
if (chestInventory instanceof TileEntityMachine) if (chestInventory instanceof TileEntityDevice)
{ {
this.sendPacket(new SPacketOpenWindow(this.currentWindowId, "machine_" + ((IInteractionObject)chestInventory).getGuiID(), chestInventory.getCommandName(), chestInventory.getSizeInventory(), this.sendPacket(new SPacketOpenWindow(this.currentWindowId, "tile", chestInventory.getCommandName(), chestInventory.getSizeInventory(),
((TileEntityMachine)chestInventory).getPos())); ((TileEntityDevice)chestInventory).getPos()));
this.entity.openContainer = ((IInteractionObject)chestInventory).createContainer(this.entity.inventory, this.entity); this.entity.openContainer = ((IInteractionObject)chestInventory).createContainer(this.entity.inventory, this.entity);
} }
else if (chestInventory instanceof IInteractionObject) else if (chestInventory instanceof IInteractionObject)
@ -720,7 +720,7 @@ public class Player extends User implements ICrafting, Executor, IPlayer
this.entity.openContainer.onCraftGuiOpened(this); 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) if (this.entity.openContainer != this.entity.inventoryContainer)
{ {
@ -728,8 +728,8 @@ public class Player extends User implements ICrafting, Executor, IPlayer
} }
this.getNextWindowId(); this.getNextWindowId();
this.sendPacket(new SPacketOpenWindow(this.currentWindowId, "EntityHorse", horseInventory.getCommandName(), horseInventory.getSizeInventory(), horse.getId())); this.sendPacket(new SPacketOpenWindow(this.currentWindowId, "entity", inventory.getCommandName(), inventory.getSizeInventory(), entity.getId()));
this.entity.openContainer = new ContainerHorseInventory(this.entity.inventory, horseInventory, horse, this.entity); this.entity.openContainer = new ContainerEntityInventory(this.entity.inventory, inventory, entity, this.entity);
this.entity.openContainer.windowId = this.currentWindowId; this.entity.openContainer.windowId = this.currentWindowId;
this.entity.openContainer.onCraftGuiOpened(this); this.entity.openContainer.onCraftGuiOpened(this);
} }