Reformat
This commit is contained in:
parent
b6e2f384ae
commit
c1912bc475
|
@ -34,44 +34,55 @@ 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)
|
||||||
TileEntity te = world.getTileEntity(pos);
|
return false;
|
||||||
TileEntityIronChest newchest = new TileEntityIronChest();
|
TileEntity te = world.getTileEntity(pos);
|
||||||
ItemStack[] chestContents = new ItemStack[27];
|
TileEntityIronChest newchest = new TileEntityIronChest();
|
||||||
if (te != null) {
|
ItemStack[] chestContents = new ItemStack[27];
|
||||||
if (te instanceof TileEntityIronChest) {
|
if (te != null)
|
||||||
chestContents = ((TileEntityIronChest) te).chestContents;
|
{
|
||||||
newchest = IronChestType.makeEntity(this.getTargetChestOrdinal(this.type.ordinal()));
|
if (te instanceof TileEntityIronChest)
|
||||||
if (newchest == null) return false;
|
{
|
||||||
} else if (te instanceof TileEntityChest) {
|
chestContents = ((TileEntityIronChest) te).chestContents;
|
||||||
if (((TileEntityChest) te).numPlayersUsing > 0) return false;
|
newchest = IronChestType.makeEntity(this.getTargetChestOrdinal(this.type.ordinal()));
|
||||||
if (!getType().canUpgrade(IronChestType.WOOD)) return false;
|
if (newchest == null)
|
||||||
chestContents = new ItemStack[((TileEntityChest) te).getSizeInventory()];
|
return false;
|
||||||
for (int i = 0; i < chestContents.length; i ++) chestContents[i] = ((TileEntityChest) te).getStackInSlot(i);
|
}
|
||||||
newchest = IronChestType.makeEntity(IronChestType.IRON.ordinal());
|
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()];
|
||||||
|
for (int i = 0; i < chestContents.length; i++)
|
||||||
|
chestContents[i] = ((TileEntityChest) te).getStackInSlot(i);
|
||||||
|
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);
|
||||||
|
|
||||||
world.setTileEntity(pos, newchest);
|
world.setTileEntity(pos, newchest);
|
||||||
world.setBlockState(pos, IronChest.ironChestBlock.getStateFromMeta(newchest.getType().ordinal()), 3);
|
world.setBlockState(pos, IronChest.ironChestBlock.getStateFromMeta(newchest.getType().ordinal()), 3);
|
||||||
|
|
||||||
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);
|
||||||
|
}
|
||||||
|
|
||||||
stack.stackSize = player.capabilities.isCreativeMode ? stack.stackSize : stack.stackSize - 1;
|
stack.stackSize = player.capabilities.isCreativeMode ? stack.stackSize : stack.stackSize - 1;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTargetChestOrdinal(int sourceOrdinal)
|
public int getTargetChestOrdinal(int sourceOrdinal)
|
||||||
|
|
|
@ -60,15 +60,18 @@ 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()];
|
{
|
||||||
for (int i = 0; i < contents.length; i ++) {
|
chestContents = new ItemStack[getSizeInventory()];
|
||||||
if (i < chestContents.length) {
|
for (int i = 0; i < contents.length; i++)
|
||||||
chestContents[i] = contents[i];
|
{
|
||||||
}
|
if (i < chestContents.length)
|
||||||
}
|
{
|
||||||
inventoryTouched = true;
|
chestContents[i] = contents[i];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
inventoryTouched = true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSizeInventory()
|
public int getSizeInventory()
|
||||||
|
|
Loading…
Reference in New Issue