2012-11-05 20:29:04 +01:00
|
|
|
package mekanism.common;
|
2012-08-15 22:41:41 +02:00
|
|
|
|
2012-12-20 22:53:39 +01:00
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
import net.minecraft.world.World;
|
2012-08-15 22:41:41 +02:00
|
|
|
|
|
|
|
public class EntityObsidianTNT extends Entity
|
|
|
|
{
|
|
|
|
/** How long the fuse is */
|
|
|
|
public int fuse;
|
|
|
|
private boolean hasExploded = false;
|
|
|
|
|
|
|
|
public EntityObsidianTNT(World par1World)
|
|
|
|
{
|
|
|
|
super(par1World);
|
|
|
|
fuse = 0;
|
|
|
|
preventEntitySpawning = true;
|
|
|
|
setSize(0.98F, 0.98F);
|
|
|
|
yOffset = height / 2.0F;
|
|
|
|
}
|
|
|
|
|
|
|
|
public EntityObsidianTNT(World par1World, double par2, double par4, double par6)
|
|
|
|
{
|
|
|
|
this(par1World);
|
|
|
|
setPosition(par2, par4, par6);
|
|
|
|
float var8 = (float)(Math.random() * Math.PI * 2.0D);
|
|
|
|
motionX = (double)(-((float)Math.sin((double)var8)) * 0.02F);
|
|
|
|
motionY = 0.20000000298023224D;
|
|
|
|
motionZ = (double)(-((float)Math.cos((double)var8)) * 0.02F);
|
2012-11-05 20:29:04 +01:00
|
|
|
fuse = Mekanism.ObsidianTNTDelay;
|
2012-08-15 22:41:41 +02:00
|
|
|
prevPosX = par2;
|
|
|
|
prevPosY = par4;
|
|
|
|
prevPosZ = par6;
|
|
|
|
}
|
|
|
|
|
2012-11-06 16:44:14 +01:00
|
|
|
@Override
|
2012-08-15 22:41:41 +02:00
|
|
|
protected void entityInit() {}
|
|
|
|
|
2012-11-06 16:44:14 +01:00
|
|
|
@Override
|
2012-08-15 22:41:41 +02:00
|
|
|
protected boolean canTriggerWalking()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-11-06 16:44:14 +01:00
|
|
|
@Override
|
2012-08-15 22:41:41 +02:00
|
|
|
public boolean canBeCollidedWith()
|
|
|
|
{
|
|
|
|
return !isDead;
|
|
|
|
}
|
2012-11-06 16:44:14 +01:00
|
|
|
|
|
|
|
@Override
|
2012-08-15 22:41:41 +02:00
|
|
|
public void onUpdate()
|
|
|
|
{
|
|
|
|
prevPosX = posX;
|
|
|
|
prevPosY = posY;
|
|
|
|
prevPosZ = posZ;
|
|
|
|
motionY -= 0.03999999910593033D;
|
|
|
|
moveEntity(motionX, motionY, motionZ);
|
|
|
|
motionX *= 0.9800000190734863D;
|
|
|
|
motionY *= 0.9800000190734863D;
|
|
|
|
motionZ *= 0.9800000190734863D;
|
|
|
|
|
|
|
|
if (onGround)
|
|
|
|
{
|
|
|
|
motionX *= 0.699999988079071D;
|
|
|
|
motionZ *= 0.699999988079071D;
|
|
|
|
motionY *= -0.5D;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fuse-- <= 0)
|
|
|
|
{
|
|
|
|
if (!worldObj.isRemote)
|
|
|
|
{
|
|
|
|
setDead();
|
|
|
|
explode();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(hasExploded)
|
|
|
|
{
|
|
|
|
setDead();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
worldObj.spawnParticle("lava", posX, posY + 0.5D, posZ, 0.0D, 0.0D, 0.0D);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
worldObj.spawnParticle("lava", posX, posY + 0.5D, posZ, 0.0D, 0.0D, 0.0D);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void explode()
|
|
|
|
{
|
2012-11-05 20:29:04 +01:00
|
|
|
worldObj.createExplosion((Entity)null, posX, posY, posZ, Mekanism.ObsidianTNTBlastRadius, true);
|
2012-08-15 22:41:41 +02:00
|
|
|
hasExploded = true;
|
|
|
|
}
|
|
|
|
|
2012-11-06 16:44:14 +01:00
|
|
|
@Override
|
2012-08-15 22:41:41 +02:00
|
|
|
protected void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
|
|
|
|
{
|
|
|
|
par1NBTTagCompound.setByte("Fuse", (byte)fuse);
|
|
|
|
}
|
|
|
|
|
2012-11-06 16:44:14 +01:00
|
|
|
@Override
|
2012-08-15 22:41:41 +02:00
|
|
|
protected void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
|
|
|
|
{
|
|
|
|
fuse = par1NBTTagCompound.getByte("Fuse");
|
|
|
|
}
|
|
|
|
|
2012-11-06 16:44:14 +01:00
|
|
|
@Override
|
2012-08-15 22:41:41 +02:00
|
|
|
public float getShadowSize()
|
|
|
|
{
|
|
|
|
return 0.0F;
|
|
|
|
}
|
|
|
|
}
|