EntityMagmaCube .java

net.minecraft.entity.monster.EntityMagmaCube (class, 175 lines): members: alterSquishAmount, getAttackStrength, makesSoundOnLand, canDamagePlayer, jump.

net.minecraft.entity.monsterclass175 linescommonextends EntitySlime4.3 KB

API Surface (20)

void applyEntityAttributes()
boolean getCanSpawnHere()
boolean isNotColliding()
int getTotalArmorValue()
int getBrightnessForRender(float partialTicks)
float getBrightness(float partialTicks)
EnumParticleTypes getParticleType()
EntitySlime createInstance()
Item getDropItem()
void dropFewItems(boolean wasRecentlyHit, int lootingModifier)
boolean isBurning()
int getJumpDelay()
void alterSquishAmount()
void jump()
void handleJumpLava()
void fall(float distance, float damageMultiplier)
boolean canDamagePlayer()
int getAttackStrength()
String getJumpSound()
boolean makesSoundOnLand()

String literals (2)

"mob.magmacube.big"
"mob.magmacube.small"

Code Graph: Dependencies (7)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

EntityMagmaCube.java175 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.entity.monster;
2
3
import net.minecraft.entity.SharedMonsterAttributes;
4
import net.minecraft.init.Items;
5
import net.minecraft.item.Item;
6
import net.minecraft.util.EnumParticleTypes;
7
import net.minecraft.world.EnumDifficulty;
8
import net.minecraft.world.World;
9
10
public class EntityMagmaCube extends EntitySlime
11
{
12
    public EntityMagmaCube(World worldIn)
13
    {
14
        super(worldIn);
15
        this.isImmuneToFire = true;
16
    }
17
18
    protected void applyEntityAttributes()
19
    {
20
        super.applyEntityAttributes();
21
        this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.20000000298023224D);
22
    }
23
24
    /**
25
     * Checks if the entity's current position is a valid location to spawn this entity.
26
     */
27
    public boolean getCanSpawnHere()
28
    {
29
        return this.worldObj.getDifficulty() != EnumDifficulty.PEACEFUL;
30
    }
31
32
    /**
33
     * Checks that the entity is not colliding with any blocks / liquids
34
     */
35
    public boolean isNotColliding()
36
    {
37
        return this.worldObj.checkNoEntityCollision(this.getEntityBoundingBox(), this) && this.worldObj.getCollidingBoundingBoxes(this, this.getEntityBoundingBox()).isEmpty() && !this.worldObj.isAnyLiquid(this.getEntityBoundingBox());
38
    }
39
40
    /**
41
     * Returns the current armor value as determined by a call to InventoryPlayer.getTotalArmorValue
42
     */
43
    public int getTotalArmorValue()
44
    {
45
        return this.getSlimeSize() * 3;
46
    }
47
48
    public int getBrightnessForRender(float partialTicks)
49
    {
50
        return 15728880;
51
    }
52
53
    /**
54
     * Gets how bright this entity is.
55
     */
56
    public float getBrightness(float partialTicks)
57
    {
58
        return 1.0F;
59
    }
60
61
    protected EnumParticleTypes getParticleType()
62
    {
63
        return EnumParticleTypes.FLAME;
64
    }
65
66
    protected EntitySlime createInstance()
67
    {
68
        return new EntityMagmaCube(this.worldObj);
69
    }
70
71
    protected Item getDropItem()
72
    {
73
        return Items.magma_cream;
74
    }
75
76
    /**
77
     * Drop 0-2 items of this living's type
78
     *  
79
     * @param wasRecentlyHit true if this this entity was recently hit by appropriate entity (generally only if player
80
     * or tameable)
81
     * @param lootingModifier level of enchanment to be applied to this drop
82
     */
83
    protected void dropFewItems(boolean wasRecentlyHit, int lootingModifier)
84
    {
85
        Item item = this.getDropItem();
86
87
        if (item != null && this.getSlimeSize() > 1)
88
        {
89
            int i = this.rand.nextInt(4) - 2;
90
91
            if (lootingModifier > 0)
92
            {
93
                i += this.rand.nextInt(lootingModifier + 1);
94
            }
95
96
            for (int j = 0; j < i; ++j)
97
            {
98
                this.dropItem(item, 1);
99
            }
100
        }
101
    }
102
103
    /**
104
     * Returns true if the entity is on fire. Used by render to add the fire effect on rendering.
105
     */
106
    public boolean isBurning()
107
    {
108
        return false;
109
    }
110
111
    /**
112
     * Gets the amount of time the slime needs to wait between jumps.
113
     */
114
    protected int getJumpDelay()
115
    {
116
        return super.getJumpDelay() * 4;
117
    }
118
119
    protected void alterSquishAmount()
120
    {
121
        this.squishAmount *= 0.9F;
122
    }
123
124
    /**
125
     * Causes this entity to do an upwards motion (jumping).
126
     */
127
    protected void jump()
128
    {
129
        this.motionY = (double)(0.42F + (float)this.getSlimeSize() * 0.1F);
130
        this.isAirBorne = true;
131
    }
132
133
    protected void handleJumpLava()
134
    {
135
        this.motionY = (double)(0.22F + (float)this.getSlimeSize() * 0.05F);
136
        this.isAirBorne = true;
137
    }
138
139
    public void fall(float distance, float damageMultiplier)
140
    {
141
    }
142
143
    /**
144
     * Indicates weather the slime is able to damage the player (based upon the slime's size)
145
     */
146
    protected boolean canDamagePlayer()
147
    {
148
        return true;
149
    }
150
151
    /**
152
     * Gets the amount of damage dealt to the player when "attacked" by the slime.
153
     */
154
    protected int getAttackStrength()
155
    {
156
        return super.getAttackStrength() + 2;
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
     * Returns true if the slime makes a sound when it lands after a jump (based upon the slime's size)
169
     */
170
    protected boolean makesSoundOnLand()
171
    {
172
        return true;
173
    }
174
}
175

Deobfuscated MCP 1.8.9 source of EntityMagmaCube from Marcelektro/MavenMCP-1.8.9 (net/minecraft/entity/monster/EntityMagmaCube.java), stored verbatim.