001 package net.minecraft.entity.monster;
002
003 import cpw.mods.fml.relauncher.Side;
004 import cpw.mods.fml.relauncher.SideOnly;
005 import net.minecraft.item.Item;
006 import net.minecraft.world.World;
007
008 public 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.shiftedIndex;
067 }
068
069 /**
070 * Drop 0-2 items of this living's type
071 */
072 protected void dropFewItems(boolean par1, int par2)
073 {
074 int var3 = this.getDropItemId();
075
076 if (var3 > 0 && this.getSlimeSize() > 1)
077 {
078 int var4 = this.rand.nextInt(4) - 2;
079
080 if (par2 > 0)
081 {
082 var4 += this.rand.nextInt(par2 + 1);
083 }
084
085 for (int var5 = 0; var5 < var4; ++var5)
086 {
087 this.dropItem(var3, 1);
088 }
089 }
090 }
091
092 /**
093 * Returns true if the entity is on fire. Used by render to add the fire effect on rendering.
094 */
095 public boolean isBurning()
096 {
097 return false;
098 }
099
100 /**
101 * Gets the amount of time the slime needs to wait between jumps.
102 */
103 protected int getJumpDelay()
104 {
105 return super.getJumpDelay() * 4;
106 }
107
108 protected void func_70808_l()
109 {
110 this.field_70813_a *= 0.9F;
111 }
112
113 /**
114 * Causes this entity to do an upwards motion (jumping).
115 */
116 protected void jump()
117 {
118 this.motionY = (double)(0.42F + (float)this.getSlimeSize() * 0.1F);
119 this.isAirBorne = true;
120 }
121
122 /**
123 * Called when the mob is falling. Calculates and applies fall damage.
124 */
125 protected void fall(float par1) {}
126
127 /**
128 * Indicates weather the slime is able to damage the player (based upon the slime's size)
129 */
130 protected boolean canDamagePlayer()
131 {
132 return true;
133 }
134
135 /**
136 * Gets the amount of damage dealt to the player when "attacked" by the slime.
137 */
138 protected int getAttackStrength()
139 {
140 return super.getAttackStrength() + 2;
141 }
142
143 /**
144 * Returns the sound this mob makes when it is hurt.
145 */
146 protected String getHurtSound()
147 {
148 return "mob.slime." + (this.getSlimeSize() > 1 ? "big" : "small");
149 }
150
151 /**
152 * Returns the sound this mob makes on death.
153 */
154 protected String getDeathSound()
155 {
156 return "mob.slime." + (this.getSlimeSize() > 1 ? "big" : "small");
157 }
158
159 /**
160 * Returns the name of the sound played when the slime jumps.
161 */
162 protected String getJumpSound()
163 {
164 return this.getSlimeSize() > 1 ? "mob.magmacube.big" : "mob.magmacube.small";
165 }
166
167 /**
168 * Whether or not the current entity is in lava
169 */
170 public boolean handleLavaMovement()
171 {
172 return false;
173 }
174
175 /**
176 * Returns true if the slime makes a sound when it lands after a jump (based upon the slime's size)
177 */
178 protected boolean makesSoundOnLand()
179 {
180 return true;
181 }
182 }