EntityWaterMob .java

net.minecraft.entity.passive.EntityWaterMob (class, 90 lines): members: canBreatheUnderwater, isPushedByWater, onEntityUpdate, getTalkInterval, canDespawn.

net.minecraft.entity.passiveclass90 linescommonextends EntityLiving1.9 KB

Implements

API Surface (8)

boolean canBreatheUnderwater()
boolean getCanSpawnHere()
boolean isNotColliding()
int getTalkInterval()
boolean canDespawn()
int getExperiencePoints(EntityPlayer player)
void onEntityUpdate()
boolean isPushedByWater()

Code Graph: Dependencies (5)

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

Full Source

EntityWaterMob.java90 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.entity.passive;
2
3
import net.minecraft.entity.EntityLiving;
4
import net.minecraft.entity.player.EntityPlayer;
5
import net.minecraft.util.DamageSource;
6
import net.minecraft.world.World;
7
8
public abstract class EntityWaterMob extends EntityLiving implements IAnimals
9
{
10
    public EntityWaterMob(World worldIn)
11
    {
12
        super(worldIn);
13
    }
14
15
    public boolean canBreatheUnderwater()
16
    {
17
        return true;
18
    }
19
20
    /**
21
     * Checks if the entity's current position is a valid location to spawn this entity.
22
     */
23
    public boolean getCanSpawnHere()
24
    {
25
        return true;
26
    }
27
28
    /**
29
     * Checks that the entity is not colliding with any blocks / liquids
30
     */
31
    public boolean isNotColliding()
32
    {
33
        return this.worldObj.checkNoEntityCollision(this.getEntityBoundingBox(), this);
34
    }
35
36
    /**
37
     * Get number of ticks, at least during which the living entity will be silent.
38
     */
39
    public int getTalkInterval()
40
    {
41
        return 120;
42
    }
43
44
    /**
45
     * Determines if an entity can be despawned, used on idle far away entities
46
     */
47
    protected boolean canDespawn()
48
    {
49
        return true;
50
    }
51
52
    /**
53
     * Get the experience points the entity currently has.
54
     */
55
    protected int getExperiencePoints(EntityPlayer player)
56
    {
57
        return 1 + this.worldObj.rand.nextInt(3);
58
    }
59
60
    /**
61
     * Gets called every tick from main Entity class
62
     */
63
    public void onEntityUpdate()
64
    {
65
        int i = this.getAir();
66
        super.onEntityUpdate();
67
68
        if (this.isEntityAlive() && !this.isInWater())
69
        {
70
            --i;
71
            this.setAir(i);
72
73
            if (this.getAir() == -20)
74
            {
75
                this.setAir(0);
76
                this.attackEntityFrom(DamageSource.drown, 2.0F);
77
            }
78
        }
79
        else
80
        {
81
            this.setAir(300);
82
        }
83
    }
84
85
    public boolean isPushedByWater()
86
    {
87
        return false;
88
    }
89
}
90

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