EntityEnderCrystal .java

net.minecraft.entity.item.EntityEnderCrystal (class): members: innerRotation, health, canBeCollidedWith, canTriggerWalking, attackEntityFrom, entityInit.

net.minecraft.entity.itemclass119 linescommonextends Entity3.2 KB

API Surface (7)

boolean canTriggerWalking()
void entityInit()
void onUpdate()
void writeEntityToNBT(NBTTagCompound tagCompound)
void readEntityFromNBT(NBTTagCompound tagCompund)
boolean canBeCollidedWith()
boolean attackEntityFrom(DamageSource source, float amount)

Fields & Constants (2)

innerRotation
health

Full Source

EntityEnderCrystal.java119 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.entity.item;
2
3
import net.minecraft.entity.Entity;
4
import net.minecraft.init.Blocks;
5
import net.minecraft.nbt.NBTTagCompound;
6
import net.minecraft.util.BlockPos;
7
import net.minecraft.util.DamageSource;
8
import net.minecraft.util.MathHelper;
9
import net.minecraft.world.World;
10
import net.minecraft.world.WorldProviderEnd;
11
12
public class EntityEnderCrystal extends Entity
13
{
14
    /** Used to create the rotation animation when rendering the crystal. */
15
    public int innerRotation;
16
    public int health;
17
18
    public EntityEnderCrystal(World worldIn)
19
    {
20
        super(worldIn);
21
        this.preventEntitySpawning = true;
22
        this.setSize(2.0F, 2.0F);
23
        this.health = 5;
24
        this.innerRotation = this.rand.nextInt(100000);
25
    }
26
27
    public EntityEnderCrystal(World worldIn, double x, double y, double z)
28
    {
29
        this(worldIn);
30
        this.setPosition(x, y, z);
31
    }
32
33
    /**
34
     * returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to
35
     * prevent them from trampling crops
36
     */
37
    protected boolean canTriggerWalking()
38
    {
39
        return false;
40
    }
41
42
    protected void entityInit()
43
    {
44
        this.dataWatcher.addObject(8, Integer.valueOf(this.health));
45
    }
46
47
    /**
48
     * Called to update the entity's position/logic.
49
     */
50
    public void onUpdate()
51
    {
52
        this.prevPosX = this.posX;
53
        this.prevPosY = this.posY;
54
        this.prevPosZ = this.posZ;
55
        ++this.innerRotation;
56
        this.dataWatcher.updateObject(8, Integer.valueOf(this.health));
57
        int i = MathHelper.floor_double(this.posX);
58
        int j = MathHelper.floor_double(this.posY);
59
        int k = MathHelper.floor_double(this.posZ);
60
61
        if (this.worldObj.provider instanceof WorldProviderEnd && this.worldObj.getBlockState(new BlockPos(i, j, k)).getBlock() != Blocks.fire)
62
        {
63
            this.worldObj.setBlockState(new BlockPos(i, j, k), Blocks.fire.getDefaultState());
64
        }
65
    }
66
67
    /**
68
     * (abstract) Protected helper method to write subclass entity data to NBT.
69
     */
70
    protected void writeEntityToNBT(NBTTagCompound tagCompound)
71
    {
72
    }
73
74
    /**
75
     * (abstract) Protected helper method to read subclass entity data from NBT.
76
     */
77
    protected void readEntityFromNBT(NBTTagCompound tagCompund)
78
    {
79
    }
80
81
    /**
82
     * Returns true if other Entities should be prevented from moving through this Entity.
83
     */
84
    public boolean canBeCollidedWith()
85
    {
86
        return true;
87
    }
88
89
    /**
90
     * Called when the entity is attacked.
91
     */
92
    public boolean attackEntityFrom(DamageSource source, float amount)
93
    {
94
        if (this.isEntityInvulnerable(source))
95
        {
96
            return false;
97
        }
98
        else
99
        {
100
            if (!this.isDead && !this.worldObj.isRemote)
101
            {
102
                this.health = 0;
103
104
                if (this.health <= 0)
105
                {
106
                    this.setDead();
107
108
                    if (!this.worldObj.isRemote)
109
                    {
110
                        this.worldObj.createExplosion((Entity)null, this.posX, this.posY, this.posZ, 6.0F, true);
111
                    }
112
                }
113
            }
114
115
            return true;
116
        }
117
    }
118
}
119

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