Fix up a possible problem when upgrading vanilla chests (hopefully)

This commit is contained in:
Christian 2012-07-10 15:02:09 -04:00
parent 500a7aa212
commit 33cb3c31f2
1 changed files with 9 additions and 0 deletions

View File

@ -49,6 +49,8 @@ public class ItemChestChanger extends Item implements ITextureProvider {
if (!getType().canUpgrade(IronChestType.WOOD)) { if (!getType().canUpgrade(IronChestType.WOOD)) {
return false; return false;
} }
org.lwjgl.input.Mouse.setGrabbed(false);
// Force old TE out of the world so that adjacent chests can update
newchest = IronChestType.makeEntity(getTargetChestOrdinal(IronChestType.WOOD.ordinal())); newchest = IronChestType.makeEntity(getTargetChestOrdinal(IronChestType.WOOD.ordinal()));
int newSize = newchest.chestContents.length; int newSize = newchest.chestContents.length;
ItemStack[] chestContents = ReflectionHelper.getPrivateValue(TileEntityChest.class, tec, 0); ItemStack[] chestContents = ReflectionHelper.getPrivateValue(TileEntityChest.class, tec, 0);
@ -61,6 +63,13 @@ public class ItemChestChanger extends Item implements ITextureProvider {
{ {
chestContents[i]=null; chestContents[i]=null;
} }
// Clear the old block out
world.setBlock(X, Y, Z, 0);
// Force the Chest TE to reset it's knowledge of neighbouring blocks
tec.updateContainingBlockInfo();
// Force the Chest TE to update any neighbours so they update next tick
tec.checkForAdjacentChests();
// And put in our block instead
world.setBlock(X, Y, Z, block.blockID); world.setBlock(X, Y, Z, block.blockID);
} else { } else {
return false; return false;