package net.minecraft.entity.item;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.ArrayList;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityHanging;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;

public class EntityPainting extends EntityHanging
{
	public EntityPainting.EnumArt art;
	private static final String __OBFID = "CL_00001556";

	public EntityPainting(World par1World)
	{
		super(par1World);
	}

	public EntityPainting(World par1World, int par2, int par3, int par4, int par5)
	{
		super(par1World, par2, par3, par4, par5);
		ArrayList arraylist = new ArrayList();
		EntityPainting.EnumArt[] aenumart = EntityPainting.EnumArt.values();
		int i1 = aenumart.length;

		for (int j1 = 0; j1 < i1; ++j1)
		{
			EntityPainting.EnumArt enumart = aenumart[j1];
			this.art = enumart;
			this.setDirection(par5);

			if (this.onValidSurface())
			{
				arraylist.add(enumart);
			}
		}

		if (!arraylist.isEmpty())
		{
			this.art = (EntityPainting.EnumArt)arraylist.get(this.rand.nextInt(arraylist.size()));
		}

		this.setDirection(par5);
	}

	@SideOnly(Side.CLIENT)
	public EntityPainting(World par1World, int par2, int par3, int par4, int par5, String par6Str)
	{
		this(par1World, par2, par3, par4, par5);
		EntityPainting.EnumArt[] aenumart = EntityPainting.EnumArt.values();
		int i1 = aenumart.length;

		for (int j1 = 0; j1 < i1; ++j1)
		{
			EntityPainting.EnumArt enumart = aenumart[j1];

			if (enumart.title.equals(par6Str))
			{
				this.art = enumart;
				break;
			}
		}

		this.setDirection(par5);
	}

	public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
	{
		par1NBTTagCompound.setString("Motive", this.art.title);
		super.writeEntityToNBT(par1NBTTagCompound);
	}

	public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
	{
		String s = par1NBTTagCompound.getString("Motive");
		EntityPainting.EnumArt[] aenumart = EntityPainting.EnumArt.values();
		int i = aenumart.length;

		for (int j = 0; j < i; ++j)
		{
			EntityPainting.EnumArt enumart = aenumart[j];

			if (enumart.title.equals(s))
			{
				this.art = enumart;
			}
		}

		if (this.art == null)
		{
			this.art = EntityPainting.EnumArt.Kebab;
		}

		super.readEntityFromNBT(par1NBTTagCompound);
	}

	public int getWidthPixels()
	{
		return this.art.sizeX;
	}

	public int getHeightPixels()
	{
		return this.art.sizeY;
	}

	public void onBroken(Entity par1Entity)
	{
		if (par1Entity instanceof EntityPlayer)
		{
			EntityPlayer entityplayer = (EntityPlayer)par1Entity;

			if (entityplayer.capabilities.isCreativeMode)
			{
				return;
			}
		}

		this.entityDropItem(new ItemStack(Items.painting), 0.0F);
	}

	public static enum EnumArt
	{
		Kebab("Kebab", 16, 16, 0, 0),
		Aztec("Aztec", 16, 16, 16, 0),
		Alban("Alban", 16, 16, 32, 0),
		Aztec2("Aztec2", 16, 16, 48, 0),
		Bomb("Bomb", 16, 16, 64, 0),
		Plant("Plant", 16, 16, 80, 0),
		Wasteland("Wasteland", 16, 16, 96, 0),
		Pool("Pool", 32, 16, 0, 32),
		Courbet("Courbet", 32, 16, 32, 32),
		Sea("Sea", 32, 16, 64, 32),
		Sunset("Sunset", 32, 16, 96, 32),
		Creebet("Creebet", 32, 16, 128, 32),
		Wanderer("Wanderer", 16, 32, 0, 64),
		Graham("Graham", 16, 32, 16, 64),
		Match("Match", 32, 32, 0, 128),
		Bust("Bust", 32, 32, 32, 128),
		Stage("Stage", 32, 32, 64, 128),
		Void("Void", 32, 32, 96, 128),
		SkullAndRoses("SkullAndRoses", 32, 32, 128, 128),
		Wither("Wither", 32, 32, 160, 128),
		Fighters("Fighters", 64, 32, 0, 96),
		Pointer("Pointer", 64, 64, 0, 192),
		Pigscene("Pigscene", 64, 64, 64, 192),
		BurningSkull("BurningSkull", 64, 64, 128, 192),
		Skeleton("Skeleton", 64, 48, 192, 64),
		DonkeyKong("DonkeyKong", 64, 48, 192, 112);
		public static final int maxArtTitleLength = "SkullAndRoses".length();
		public final String title;
		public final int sizeX;
		public final int sizeY;
		public final int offsetX;
		public final int offsetY;

		private static final String __OBFID = "CL_00001557";

		private EnumArt(String par3Str, int par4, int par5, int par6, int par7)
		{
			this.title = par3Str;
			this.sizeX = par4;
			this.sizeY = par5;
			this.offsetX = par6;
			this.offsetY = par7;
		}
	}
}