001    package net.minecraft.src;
002    
003    import cpw.mods.fml.common.Side;
004    import cpw.mods.fml.common.asm.SideOnly;
005    
006    public class EntityMagmaCube extends EntitySlime
007    {
008        public EntityMagmaCube(World par1World)
009        {
010            super(par1World);
011            this.texture = "/mob/lava.png";
012            this.isImmuneToFire = true;
013            this.landMovementFactor = 0.2F;
014        }
015    
016        /**
017         * Checks if the entity's current position is a valid location to spawn this entity.
018         */
019        public boolean getCanSpawnHere()
020        {
021            return this.worldObj.difficultySetting > 0 && this.worldObj.checkIfAABBIsClear(this.boundingBox) && this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox).isEmpty() && !this.worldObj.isAnyLiquid(this.boundingBox);
022        }
023    
024        /**
025         * Returns the current armor value as determined by a call to InventoryPlayer.getTotalArmorValue
026         */
027        public int getTotalArmorValue()
028        {
029            return this.getSlimeSize() * 3;
030        }
031    
032        @SideOnly(Side.CLIENT)
033        public int getBrightnessForRender(float par1)
034        {
035            return 15728880;
036        }
037    
038        /**
039         * Gets how bright this entity is.
040         */
041        public float getBrightness(float par1)
042        {
043            return 1.0F;
044        }
045    
046        /**
047         * Returns the name of a particle effect that may be randomly created by EntitySlime.onUpdate()
048         */
049        protected String getSlimeParticle()
050        {
051            return "flame";
052        }
053    
054        protected EntitySlime createInstance()
055        {
056            return new EntityMagmaCube(this.worldObj);
057        }
058    
059        /**
060         * Returns the item ID for the item the mob drops on death.
061         */
062        protected int getDropItemId()
063        {
064            return Item.magmaCream.shiftedIndex;
065        }
066    
067        /**
068         * Drop 0-2 items of this living's type
069         */
070        protected void dropFewItems(boolean par1, int par2)
071        {
072            int var3 = this.getDropItemId();
073    
074            if (var3 > 0 && this.getSlimeSize() > 1)
075            {
076                int var4 = this.rand.nextInt(4) - 2;
077    
078                if (par2 > 0)
079                {
080                    var4 += this.rand.nextInt(par2 + 1);
081                }
082    
083                for (int var5 = 0; var5 < var4; ++var5)
084                {
085                    this.dropItem(var3, 1);
086                }
087            }
088        }
089    
090        /**
091         * Returns true if the entity is on fire. Used by render to add the fire effect on rendering.
092         */
093        public boolean isBurning()
094        {
095            return false;
096        }
097    
098        /**
099         * Gets the amount of time the slime needs to wait between jumps.
100         */
101        protected int getJumpDelay()
102        {
103            return super.getJumpDelay() * 4;
104        }
105    
106        protected void func_70808_l()
107        {
108            this.field_70813_a *= 0.9F;
109        }
110    
111        /**
112         * Causes this entity to do an upwards motion (jumping).
113         */
114        protected void jump()
115        {
116            this.motionY = (double)(0.42F + (float)this.getSlimeSize() * 0.1F);
117            this.isAirBorne = true;
118        }
119    
120        /**
121         * Called when the mob is falling. Calculates and applies fall damage.
122         */
123        protected void fall(float par1) {}
124    
125        /**
126         * Indicates weather the slime is able to damage the player (based upon the slime's size)
127         */
128        protected boolean canDamagePlayer()
129        {
130            return true;
131        }
132    
133        /**
134         * Gets the amount of damage dealt to the player when "attacked" by the slime.
135         */
136        protected int getAttackStrength()
137        {
138            return super.getAttackStrength() + 2;
139        }
140    
141        /**
142         * Returns the sound this mob makes when it is hurt.
143         */
144        protected String getHurtSound()
145        {
146            return "mob.slime";
147        }
148    
149        /**
150         * Returns the sound this mob makes on death.
151         */
152        protected String getDeathSound()
153        {
154            return "mob.slime";
155        }
156    
157        /**
158         * Returns the name of the sound played when the slime jumps.
159         */
160        protected String getJumpSound()
161        {
162            return this.getSlimeSize() > 1 ? "mob.magmacube.big" : "mob.magmacube.small";
163        }
164    
165        /**
166         * Whether or not the current entity is in lava
167         */
168        public boolean handleLavaMovement()
169        {
170            return false;
171        }
172    
173        /**
174         * Returns true if the slime makes a sound when it lands after a jump (based upon the slime's size)
175         */
176        protected boolean makesSoundOnLand()
177        {
178            return true;
179        }
180    }