    001package net.minecraft.entity.item;
    002
    003import cpw.mods.fml.relauncher.Side;
    004import cpw.mods.fml.relauncher.SideOnly;
    005import net.minecraft.entity.Entity;
    006import net.minecraft.entity.EntityLiving;
    007import net.minecraft.nbt.NBTTagCompound;
    008import net.minecraft.world.World;
    009
    010public class EntityTNTPrimed extends Entity
    011{
    012    /** How long the fuse is */
    013    public int fuse;
    014    private EntityLiving field_94084_b;
    015
    016    public EntityTNTPrimed(World par1World)
    017    {
    018        super(par1World);
    019        this.fuse = 0;
    020        this.preventEntitySpawning = true;
    021        this.setSize(0.98F, 0.98F);
    022        this.yOffset = this.height / 2.0F;
    023    }
    024
    025    public EntityTNTPrimed(World par1World, double par2, double par4, double par6, EntityLiving par8EntityLiving)
    026    {
    027        this(par1World);
    028        this.setPosition(par2, par4, par6);
    029        float f = (float)(Math.random() * Math.PI * 2.0D);
    030        this.motionX = (double)(-((float)Math.sin((double)f)) * 0.02F);
    031        this.motionY = 0.20000000298023224D;
    032        this.motionZ = (double)(-((float)Math.cos((double)f)) * 0.02F);
    033        this.fuse = 80;
    034        this.prevPosX = par2;
    035        this.prevPosY = par4;
    036        this.prevPosZ = par6;
    037        this.field_94084_b = par8EntityLiving;
    038    }
    039
    040    protected void entityInit() {}
    041
    042    /**
    043     * returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to
    044     * prevent them from trampling crops
    045     */
    046    protected boolean canTriggerWalking()
    047    {
    048        return false;
    049    }
    050
    051    /**
    052     * Returns true if other Entities should be prevented from moving through this Entity.
    053     */
    054    public boolean canBeCollidedWith()
    055    {
    056        return !this.isDead;
    057    }
    058
    059    /**
    060     * Called to update the entity's position/logic.
    061     */
    062    public void onUpdate()
    063    {
    064        this.prevPosX = this.posX;
    065        this.prevPosY = this.posY;
    066        this.prevPosZ = this.posZ;
    067        this.motionY -= 0.03999999910593033D;
    068        this.moveEntity(this.motionX, this.motionY, this.motionZ);
    069        this.motionX *= 0.9800000190734863D;
    070        this.motionY *= 0.9800000190734863D;
    071        this.motionZ *= 0.9800000190734863D;
    072
    073        if (this.onGround)
    074        {
    075            this.motionX *= 0.699999988079071D;
    076            this.motionZ *= 0.699999988079071D;
    077            this.motionY *= -0.5D;
    078        }
    079
    080        if (this.fuse-- <= 0)
    081        {
    082            this.setDead();
    083
    084            if (!this.worldObj.isRemote)
    085            {
    086                this.explode();
    087            }
    088        }
    089        else
    090        {
    091            this.worldObj.spawnParticle("smoke", this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D);
    092        }
    093    }
    094
    095    private void explode()
    096    {
    097        float f = 4.0F;
    098        this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, f, true);
    099    }
    100
    101    /**
    102     * (abstract) Protected helper method to write subclass entity data to NBT.
    103     */
    104    protected void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
    105    {
    106        par1NBTTagCompound.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 par1NBTTagCompound)
    113    {
    114        this.fuse = par1NBTTagCompound.getByte("Fuse");
    115    }
    116
    117    @SideOnly(Side.CLIENT)
    118    public float getShadowSize()
    119    {
    120        return 0.0F;
    121    }
    122
    123    public EntityLiving func_94083_c()
    124    {
    125        return this.field_94084_b;
    126    }
    127}