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