EntityTNTPrimed .java

net.minecraft.entity.item.EntityTNTPrimed (class, 130 lines): members: getTntPlacedBy, tntPlacedBy, fuse, canBeCollidedWith, canTriggerWalking, entityInit.

net.minecraft.entity.itemclass130 linescommonextends Entity3.4 KB

API Surface (8)

void entityInit()
boolean canTriggerWalking()
boolean canBeCollidedWith()
void onUpdate()
void writeEntityToNBT(NBTTagCompound tagCompound)
void readEntityFromNBT(NBTTagCompound tagCompund)
EntityLivingBase getTntPlacedBy()
float getEyeHeight()

Fields & Constants (2)

fuse
tntPlacedBy

String literals (1)

"Fuse"

Code Graph: Dependencies (5)

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

Full Source

EntityTNTPrimed.java130 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.entity.item;
2
3
import net.minecraft.entity.Entity;
4
import net.minecraft.entity.EntityLivingBase;
5
import net.minecraft.nbt.NBTTagCompound;
6
import net.minecraft.util.EnumParticleTypes;
7
import net.minecraft.world.World;
8
9
public class EntityTNTPrimed extends Entity
10
{
11
    /** How long the fuse is */
12
    public int fuse;
13
    private EntityLivingBase tntPlacedBy;
14
15
    public EntityTNTPrimed(World worldIn)
16
    {
17
        super(worldIn);
18
        this.preventEntitySpawning = true;
19
        this.setSize(0.98F, 0.98F);
20
    }
21
22
    public EntityTNTPrimed(World worldIn, double x, double y, double z, EntityLivingBase igniter)
23
    {
24
        this(worldIn);
25
        this.setPosition(x, y, z);
26
        float f = (float)(Math.random() * Math.PI * 2.0D);
27
        this.motionX = (double)(-((float)Math.sin((double)f)) * 0.02F);
28
        this.motionY = 0.20000000298023224D;
29
        this.motionZ = (double)(-((float)Math.cos((double)f)) * 0.02F);
30
        this.fuse = 80;
31
        this.prevPosX = x;
32
        this.prevPosY = y;
33
        this.prevPosZ = z;
34
        this.tntPlacedBy = igniter;
35
    }
36
37
    protected void entityInit()
38
    {
39
    }
40
41
    /**
42
     * returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to
43
     * prevent them from trampling crops
44
     */
45
    protected boolean canTriggerWalking()
46
    {
47
        return false;
48
    }
49
50
    /**
51
     * Returns true if other Entities should be prevented from moving through this Entity.
52
     */
53
    public boolean canBeCollidedWith()
54
    {
55
        return !this.isDead;
56
    }
57
58
    /**
59
     * Called to update the entity's position/logic.
60
     */
61
    public void onUpdate()
62
    {
63
        this.prevPosX = this.posX;
64
        this.prevPosY = this.posY;
65
        this.prevPosZ = this.posZ;
66
        this.motionY -= 0.03999999910593033D;
67
        this.moveEntity(this.motionX, this.motionY, this.motionZ);
68
        this.motionX *= 0.9800000190734863D;
69
        this.motionY *= 0.9800000190734863D;
70
        this.motionZ *= 0.9800000190734863D;
71
72
        if (this.onGround)
73
        {
74
            this.motionX *= 0.699999988079071D;
75
            this.motionZ *= 0.699999988079071D;
76
            this.motionY *= -0.5D;
77
        }
78
79
        if (this.fuse-- <= 0)
80
        {
81
            this.setDead();
82
83
            if (!this.worldObj.isRemote)
84
            {
85
                this.explode();
86
            }
87
        }
88
        else
89
        {
90
            this.handleWaterMovement();
91
            this.worldObj.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D, new int[0]);
92
        }
93
    }
94
95
    private void explode()
96
    {
97
        float f = 4.0F;
98
        this.worldObj.createExplosion(this, this.posX, this.posY + (double)(this.height / 16.0F), this.posZ, f, true);
99
    }
100
101
    /**
102
     * (abstract) Protected helper method to write subclass entity data to NBT.
103
     */
104
    protected void writeEntityToNBT(NBTTagCompound tagCompound)
105
    {
106
        tagCompound.setByte("Fuse", (byte)this.fuse);
107
    }
108
109
    /**
110
     * (abstract) Protected helper method to read subclass entity data from NBT.
111
     */
112
    protected void readEntityFromNBT(NBTTagCompound tagCompund)
113
    {
114
        this.fuse = tagCompund.getByte("Fuse");
115
    }
116
117
    /**
118
     * returns null or the entityliving it was placed or ignited by
119
     */
120
    public EntityLivingBase getTntPlacedBy()
121
    {
122
        return this.tntPlacedBy;
123
    }
124
125
    public float getEyeHeight()
126
    {
127
        return 0.0F;
128
    }
129
}
130

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