make guis more generic
This commit is contained in:
parent
374e0c4617
commit
5534531416
22 changed files with 334 additions and 504 deletions
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
132
common/src/main/java/common/inventory/ContainerEntityInventory.java
Executable file
132
common/src/main/java/common/inventory/ContainerEntityInventory.java
Executable 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);
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -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)
|
|
@ -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();
|
||||
}
|
|
@ -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);
|
||||
|
|
|
@ -63,11 +63,11 @@ public class SPacketOpenWindow implements Packet<IClientPlayer>
|
|||
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<IClientPlayer>
|
|||
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<IClientPlayer>
|
|||
{
|
||||
return this.tilePos;
|
||||
}
|
||||
|
||||
public boolean hasSlots()
|
||||
{
|
||||
return this.slotCount > 0 || this.inventoryType.startsWith("machine_");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
|
@ -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));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue