    001    package net.minecraft.entity.item;
    002
    003    import cpw.mods.fml.common.Side;
    004    import cpw.mods.fml.common.asm.SideOnly;
    005    import java.util.ArrayList;
    006    import net.minecraft.entity.EntityHanging;
    007    import net.minecraft.item.Item;
    008    import net.minecraft.item.ItemStack;
    009    import net.minecraft.nbt.NBTTagCompound;
    010    import net.minecraft.util.EnumArt;
    011    import net.minecraft.world.World;
    012
    013    public 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 var6 = new ArrayList();
    026            EnumArt[] var7 = EnumArt.values();
    027            int var8 = var7.length;
    028
    029            for (int var9 = 0; var9 < var8; ++var9)
    030            {
    031                EnumArt var10 = var7[var9];
    032                this.art = var10;
    033                this.setDirection(par5);
    034
    035                if (this.onValidSurface())
    036                {
    037                    var6.add(var10);
    038                }
    039            }
    040
    041            if (!var6.isEmpty())
    042            {
    043                this.art = (EnumArt)var6.get(this.rand.nextInt(var6.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[] var7 = EnumArt.values();
    054            int var8 = var7.length;
    055
    056            for (int var9 = 0; var9 < var8; ++var9)
    057            {
    058                EnumArt var10 = var7[var9];
    059
    060                if (var10.title.equals(par6Str))
    061                {
    062                    this.art = var10;
    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 var2 = par1NBTTagCompound.getString("Motive");
    085            EnumArt[] var3 = EnumArt.values();
    086            int var4 = var3.length;
    087
    088            for (int var5 = 0; var5 < var4; ++var5)
    089            {
    090                EnumArt var6 = var3[var5];
    091
    092                if (var6.title.equals(var2))
    093                {
    094                    this.art = var6;
    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    }