Reformat
This commit is contained in:
parent
b6e2f384ae
commit
c1912bc475
|
@ -34,28 +34,38 @@ public class ItemChestChanger extends Item
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
|
public boolean onItemUseFirst (ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||||
{
|
{
|
||||||
if (world.isRemote) return false;
|
if (world.isRemote)
|
||||||
|
return false;
|
||||||
TileEntity te = world.getTileEntity(pos);
|
TileEntity te = world.getTileEntity(pos);
|
||||||
TileEntityIronChest newchest = new TileEntityIronChest();
|
TileEntityIronChest newchest = new TileEntityIronChest();
|
||||||
ItemStack[] chestContents = new ItemStack[27];
|
ItemStack[] chestContents = new ItemStack[27];
|
||||||
if (te != null) {
|
if (te != null)
|
||||||
if (te instanceof TileEntityIronChest) {
|
{
|
||||||
|
if (te instanceof TileEntityIronChest)
|
||||||
|
{
|
||||||
chestContents = ((TileEntityIronChest) te).chestContents;
|
chestContents = ((TileEntityIronChest) te).chestContents;
|
||||||
newchest = IronChestType.makeEntity(this.getTargetChestOrdinal(this.type.ordinal()));
|
newchest = IronChestType.makeEntity(this.getTargetChestOrdinal(this.type.ordinal()));
|
||||||
if (newchest == null) return false;
|
if (newchest == null)
|
||||||
} else if (te instanceof TileEntityChest) {
|
return false;
|
||||||
if (((TileEntityChest) te).numPlayersUsing > 0) return false;
|
}
|
||||||
if (!getType().canUpgrade(IronChestType.WOOD)) return false;
|
else if (te instanceof TileEntityChest)
|
||||||
|
{
|
||||||
|
if (((TileEntityChest) te).numPlayersUsing > 0)
|
||||||
|
return false;
|
||||||
|
if (!getType().canUpgrade(IronChestType.WOOD))
|
||||||
|
return false;
|
||||||
chestContents = new ItemStack[((TileEntityChest) te).getSizeInventory()];
|
chestContents = new ItemStack[((TileEntityChest) te).getSizeInventory()];
|
||||||
for (int i = 0; i < chestContents.length; i ++) chestContents[i] = ((TileEntityChest) te).getStackInSlot(i);
|
for (int i = 0; i < chestContents.length; i++)
|
||||||
|
chestContents[i] = ((TileEntityChest) te).getStackInSlot(i);
|
||||||
newchest = IronChestType.makeEntity(IronChestType.IRON.ordinal());
|
newchest = IronChestType.makeEntity(IronChestType.IRON.ordinal());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
te.updateContainingBlockInfo();
|
te.updateContainingBlockInfo();
|
||||||
if (te instanceof TileEntityChest) ((TileEntityChest) te).checkForAdjacentChests();
|
if (te instanceof TileEntityChest)
|
||||||
|
((TileEntityChest) te).checkForAdjacentChests();
|
||||||
|
|
||||||
world.removeTileEntity(pos);
|
world.removeTileEntity(pos);
|
||||||
world.setBlockToAir(pos);
|
world.setBlockToAir(pos);
|
||||||
|
@ -66,7 +76,8 @@ public class ItemChestChanger extends Item
|
||||||
world.markBlockForUpdate(pos);
|
world.markBlockForUpdate(pos);
|
||||||
|
|
||||||
TileEntity te2 = world.getTileEntity(pos);
|
TileEntity te2 = world.getTileEntity(pos);
|
||||||
if (te2 instanceof TileEntityIronChest) {
|
if (te2 instanceof TileEntityIronChest)
|
||||||
|
{
|
||||||
((TileEntityIronChest) te2).setContents(chestContents);
|
((TileEntityIronChest) te2).setContents(chestContents);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,10 +60,13 @@ public class TileEntityIronChest extends TileEntityLockable implements IUpdatePl
|
||||||
return chestContents;
|
return chestContents;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setContents(ItemStack[] contents) {
|
public void setContents (ItemStack[] contents)
|
||||||
|
{
|
||||||
chestContents = new ItemStack[getSizeInventory()];
|
chestContents = new ItemStack[getSizeInventory()];
|
||||||
for (int i = 0; i < contents.length; i ++) {
|
for (int i = 0; i < contents.length; i++)
|
||||||
if (i < chestContents.length) {
|
{
|
||||||
|
if (i < chestContents.length)
|
||||||
|
{
|
||||||
chestContents[i] = contents[i];
|
chestContents[i] = contents[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue