    001    package net.minecraft.src;
    002
    003    public class BlockPumpkin extends BlockDirectional
    004    {
    005        /** Boolean used to seperate different states of blocks */
    006        private boolean blockType;
    007
    008        protected BlockPumpkin(int par1, int par2, boolean par3)
    009        {
    010            super(par1, Material.pumpkin);
    011            this.blockIndexInTexture = par2;
    012            this.setTickRandomly(true);
    013            this.blockType = par3;
    014            this.setCreativeTab(CreativeTabs.tabBlock);
    015        }
    016
    017        /**
    018         * From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
    019         */
    020        public int getBlockTextureFromSideAndMetadata(int par1, int par2)
    021        {
    022            if (par1 == 1)
    023            {
    024                return this.blockIndexInTexture;
    025            }
    026            else if (par1 == 0)
    027            {
    028                return this.blockIndexInTexture;
    029            }
    030            else
    031            {
    032                int var3 = this.blockIndexInTexture + 1 + 16;
    033
    034                if (this.blockType)
    035                {
    036                    ++var3;
    037                }
    038
    039                return par2 == 2 && par1 == 2 ? var3 : (par2 == 3 && par1 == 5 ? var3 : (par2 == 0 && par1 == 3 ? var3 : (par2 == 1 && par1 == 4 ? var3 : this.blockIndexInTexture + 16)));
    040            }
    041        }
    042
    043        /**
    044         * Returns the block texture based on the side being looked at.  Args: side
    045         */
    046        public int getBlockTextureFromSide(int par1)
    047        {
    048            return par1 == 1 ? this.blockIndexInTexture : (par1 == 0 ? this.blockIndexInTexture : (par1 == 3 ? this.blockIndexInTexture + 1 + 16 : this.blockIndexInTexture + 16));
    049        }
    050
    051        /**
    052         * Called whenever the block is added into the world. Args: world, x, y, z
    053         */
    054        public void onBlockAdded(World par1World, int par2, int par3, int par4)
    055        {
    056            super.onBlockAdded(par1World, par2, par3, par4);
    057
    058            if (par1World.getBlockId(par2, par3 - 1, par4) == Block.blockSnow.blockID && par1World.getBlockId(par2, par3 - 2, par4) == Block.blockSnow.blockID)
    059            {
    060                if (!par1World.isRemote)
    061                {
    062                    par1World.setBlock(par2, par3, par4, 0);
    063                    par1World.setBlock(par2, par3 - 1, par4, 0);
    064                    par1World.setBlock(par2, par3 - 2, par4, 0);
    065                    EntitySnowman var9 = new EntitySnowman(par1World);
    066                    var9.setLocationAndAngles((double)par2 + 0.5D, (double)par3 - 1.95D, (double)par4 + 0.5D, 0.0F, 0.0F);
    067                    par1World.spawnEntityInWorld(var9);
    068                    par1World.notifyBlockChange(par2, par3, par4, 0);
    069                    par1World.notifyBlockChange(par2, par3 - 1, par4, 0);
    070                    par1World.notifyBlockChange(par2, par3 - 2, par4, 0);
    071                }
    072
    073                for (int var10 = 0; var10 < 120; ++var10)
    074                {
    075                    par1World.spawnParticle("snowshovel", (double)par2 + par1World.rand.nextDouble(), (double)(par3 - 2) + par1World.rand.nextDouble() * 2.5D, (double)par4 + par1World.rand.nextDouble(), 0.0D, 0.0D, 0.0D);
    076                }
    077            }
    078            else if (par1World.getBlockId(par2, par3 - 1, par4) == Block.blockSteel.blockID && par1World.getBlockId(par2, par3 - 2, par4) == Block.blockSteel.blockID)
    079            {
    080                boolean var5 = par1World.getBlockId(par2 - 1, par3 - 1, par4) == Block.blockSteel.blockID && par1World.getBlockId(par2 + 1, par3 - 1, par4) == Block.blockSteel.blockID;
    081                boolean var6 = par1World.getBlockId(par2, par3 - 1, par4 - 1) == Block.blockSteel.blockID && par1World.getBlockId(par2, par3 - 1, par4 + 1) == Block.blockSteel.blockID;
    082
    083                if (var5 || var6)
    084                {
    085                    par1World.setBlock(par2, par3, par4, 0);
    086                    par1World.setBlock(par2, par3 - 1, par4, 0);
    087                    par1World.setBlock(par2, par3 - 2, par4, 0);
    088
    089                    if (var5)
    090                    {
    091                        par1World.setBlock(par2 - 1, par3 - 1, par4, 0);
    092                        par1World.setBlock(par2 + 1, par3 - 1, par4, 0);
    093                    }
    094                    else
    095                    {
    096                        par1World.setBlock(par2, par3 - 1, par4 - 1, 0);
    097                        par1World.setBlock(par2, par3 - 1, par4 + 1, 0);
    098                    }
    099
    100                    EntityIronGolem var7 = new EntityIronGolem(par1World);
    101                    var7.setBit1FlagTo(true);
    102                    var7.setLocationAndAngles((double)par2 + 0.5D, (double)par3 - 1.95D, (double)par4 + 0.5D, 0.0F, 0.0F);
    103                    par1World.spawnEntityInWorld(var7);
    104
    105                    for (int var8 = 0; var8 < 120; ++var8)
    106                    {
    107                        par1World.spawnParticle("snowballpoof", (double)par2 + par1World.rand.nextDouble(), (double)(par3 - 2) + par1World.rand.nextDouble() * 3.9D, (double)par4 + par1World.rand.nextDouble(), 0.0D, 0.0D, 0.0D);
    108                    }
    109
    110                    par1World.notifyBlockChange(par2, par3, par4, 0);
    111                    par1World.notifyBlockChange(par2, par3 - 1, par4, 0);
    112                    par1World.notifyBlockChange(par2, par3 - 2, par4, 0);
    113
    114                    if (var5)
    115                    {
    116                        par1World.notifyBlockChange(par2 - 1, par3 - 1, par4, 0);
    117                        par1World.notifyBlockChange(par2 + 1, par3 - 1, par4, 0);
    118                    }
    119                    else
    120                    {
    121                        par1World.notifyBlockChange(par2, par3 - 1, par4 - 1, 0);
    122                        par1World.notifyBlockChange(par2, par3 - 1, par4 + 1, 0);
    123                    }
    124                }
    125            }
    126        }
    127
    128        /**
    129         * Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z
    130         */
    131        public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4)
    132        {
    133            int var5 = par1World.getBlockId(par2, par3, par4);
    134            return (var5 == 0 || Block.blocksList[var5].blockMaterial.isGroundCover()) && par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4);
    135        }
    136
    137        /**
    138         * Called when the block is placed in the world.
    139         */
    140        public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving)
    141        {
    142            int var6 = MathHelper.floor_double((double)(par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 2.5D) & 3;
    143            par1World.setBlockMetadataWithNotify(par2, par3, par4, var6);
    144        }
    145    }