package ganymedes01.etfuturum.core.handlers;

import java.util.List;

import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
import cpw.mods.fml.common.gameevent.TickEvent.WorldTickEvent;
import cpw.mods.fml.relauncher.Side;
import ganymedes01.etfuturum.ModBlocks;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;

public class WorldTickEventHandler {

	private boolean isReplacing = false;

	@SubscribeEvent
	@SuppressWarnings("unchecked")
	public void tick(WorldTickEvent event) {
		if (event.side != Side.SERVER || event.phase != Phase.END || isReplacing)
			return;

		isReplacing = true;
		World world = event.world;
		for (TileEntity tile : (List<TileEntity>) world.loadedTileEntityList) {
			Block block = world.getBlock(tile.xCoord, tile.yCoord, tile.zCoord);
			if (block == Blocks.brewing_stand) {
				world.setBlock(tile.xCoord, tile.yCoord, tile.zCoord, ModBlocks.brewing_stand);
				return;
			}
		}
		isReplacing = false;
	}
}
@@ -373,32 +373,116 @@
 ft.init.Blocks;%0A
+import net.minecraft.inventory.IInventory;%0Aimport net.minecraft.nbt.NBTTagCompound;%0A
 import net.minec
@@ -1045,85 +1045,460 @@
 %09%09%09%09
-world.setBlock(tile.xCoord, tile.yCoord, tile.zCoord, ModBlocks.brewing_stand
+NBTTagCompound nbt = new NBTTagCompound();%0A%09%09%09%09tile.writeToNBT(nbt);%0A%09%09%09%09if (tile instanceof IInventory) %7B%0A%09%09%09%09%09IInventory invt = (IInventory) tile;%0A%09%09%09%09%09for (int i = 0; i %3C invt.getSizeInventory(); i++)%0A%09%09%09%09%09%09invt.setInventorySlotContents(i, null);%0A%09%09%09%09%7D%0A%09%09%09%09world.setBlock(tile.xCoord, tile.yCoord, tile.zCoord, ModBlocks.brewing_stand);%0A%09%09%09%09TileEntity newTile = world.getTileEntity(tile.xCoord, tile.yCoord, tile.zCoord);%0A%09%09%09%09newTile.readFromNBT(nbt
 );%0A%09

Fix old brewing stands losing their inventory contents