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