package net.minecraft.tileentity;

import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.world.World;

public class TileEntityMobSpawner extends TileEntity
{
	private final MobSpawnerBaseLogic field_145882_a = new MobSpawnerBaseLogic()
	{
		private static final String __OBFID = "CL_00000361";
		public void func_98267_a(int par1)
		{
			TileEntityMobSpawner.this.worldObj.addBlockEvent(TileEntityMobSpawner.this.xCoord, TileEntityMobSpawner.this.yCoord, TileEntityMobSpawner.this.zCoord, Blocks.mob_spawner, par1, 0);
		}
		public World getSpawnerWorld()
		{
			return TileEntityMobSpawner.this.worldObj;
		}
		public int getSpawnerX()
		{
			return TileEntityMobSpawner.this.xCoord;
		}
		public int getSpawnerY()
		{
			return TileEntityMobSpawner.this.yCoord;
		}
		public int getSpawnerZ()
		{
			return TileEntityMobSpawner.this.zCoord;
		}
		public void setRandomEntity(MobSpawnerBaseLogic.WeightedRandomMinecart par1WeightedRandomMinecart)
		{
			super.setRandomEntity(par1WeightedRandomMinecart);

			if (this.getSpawnerWorld() != null)
			{
				this.getSpawnerWorld().markBlockForUpdate(TileEntityMobSpawner.this.xCoord, TileEntityMobSpawner.this.yCoord, TileEntityMobSpawner.this.zCoord);
			}
		}
	};
	private static final String __OBFID = "CL_00000360";

	public void readFromNBT(NBTTagCompound p_145839_1_)
	{
		super.readFromNBT(p_145839_1_);
		this.field_145882_a.readFromNBT(p_145839_1_);
	}

	public void writeToNBT(NBTTagCompound p_145841_1_)
	{
		super.writeToNBT(p_145841_1_);
		this.field_145882_a.writeToNBT(p_145841_1_);
	}

	public void updateEntity()
	{
		this.field_145882_a.updateSpawner();
		super.updateEntity();
	}

	public Packet getDescriptionPacket()
	{
		NBTTagCompound nbttagcompound = new NBTTagCompound();
		this.writeToNBT(nbttagcompound);
		nbttagcompound.removeTag("SpawnPotentials");
		return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, nbttagcompound);
	}

	public boolean receiveClientEvent(int p_145842_1_, int p_145842_2_)
	{
		return this.field_145882_a.setDelayToMin(p_145842_1_) ? true : super.receiveClientEvent(p_145842_1_, p_145842_2_);
	}

	public MobSpawnerBaseLogic func_145881_a()
	{
		return this.field_145882_a;
	}
}