    001package net.minecraft.entity.item;
    002
    003import cpw.mods.fml.relauncher.Side;
    004import cpw.mods.fml.relauncher.SideOnly;
    005import java.util.ArrayList;
    006import net.minecraft.entity.EntityHanging;
    007import net.minecraft.item.Item;
    008import net.minecraft.item.ItemStack;
    009import net.minecraft.nbt.NBTTagCompound;
    010import net.minecraft.util.EnumArt;
    011import net.minecraft.world.World;
    012
    013public class EntityPainting extends EntityHanging
    014{
    015    public EnumArt art;
    016
    017    public EntityPainting(World par1World)
    018    {
    019        super(par1World);
    020    }
    021
    022    public EntityPainting(World par1World, int par2, int par3, int par4, int par5)
    023    {
    024        super(par1World, par2, par3, par4, par5);
    025        ArrayList arraylist = new ArrayList();
    026        EnumArt[] aenumart = EnumArt.values();
    027        int i1 = aenumart.length;
    028
    029        for (int j1 = 0; j1 < i1; ++j1)
    030        {
    031            EnumArt enumart = aenumart[j1];
    032            this.art = enumart;
    033            this.setDirection(par5);
    034
    035            if (this.onValidSurface())
    036            {
    037                arraylist.add(enumart);
    038            }
    039        }
    040
    041        if (!arraylist.isEmpty())
    042        {
    043            this.art = (EnumArt)arraylist.get(this.rand.nextInt(arraylist.size()));
    044        }
    045
    046        this.setDirection(par5);
    047    }
    048
    049    @SideOnly(Side.CLIENT)
    050    public EntityPainting(World par1World, int par2, int par3, int par4, int par5, String par6Str)
    051    {
    052        this(par1World, par2, par3, par4, par5);
    053        EnumArt[] aenumart = EnumArt.values();
    054        int i1 = aenumart.length;
    055
    056        for (int j1 = 0; j1 < i1; ++j1)
    057        {
    058            EnumArt enumart = aenumart[j1];
    059
    060            if (enumart.title.equals(par6Str))
    061            {
    062                this.art = enumart;
    063                break;
    064            }
    065        }
    066
    067        this.setDirection(par5);
    068    }
    069
    070    /**
    071     * (abstract) Protected helper method to write subclass entity data to NBT.
    072     */
    073    public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
    074    {
    075        par1NBTTagCompound.setString("Motive", this.art.title);
    076        super.writeEntityToNBT(par1NBTTagCompound);
    077    }
    078
    079    /**
    080     * (abstract) Protected helper method to read subclass entity data from NBT.
    081     */
    082    public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
    083    {
    084        String s = par1NBTTagCompound.getString("Motive");
    085        EnumArt[] aenumart = EnumArt.values();
    086        int i = aenumart.length;
    087
    088        for (int j = 0; j < i; ++j)
    089        {
    090            EnumArt enumart = aenumart[j];
    091
    092            if (enumart.title.equals(s))
    093            {
    094                this.art = enumart;
    095            }
    096        }
    097
    098        if (this.art == null)
    099        {
    100            this.art = EnumArt.Kebab;
    101        }
    102
    103        super.readEntityFromNBT(par1NBTTagCompound);
    104    }
    105
    106    public int func_82329_d()
    107    {
    108        return this.art.sizeX;
    109    }
    110
    111    public int func_82330_g()
    112    {
    113        return this.art.sizeY;
    114    }
    115
    116    /**
    117     * Drop the item currently on this item frame.
    118     */
    119    public void dropItemStack()
    120    {
    121        this.entityDropItem(new ItemStack(Item.painting), 0.0F);
    122    }
    123}