Files
MML/src/net/minecraft/src/mml/Entities/EntityNukePrimed.java

94 lines
2.5 KiB
Java

package net.minecraft.src.mml.Entities;
import net.minecraft.src.Entity;
import net.minecraft.src.EntityLiving;
import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.World;
public class EntityNukePrimed extends Entity {
private EntityLiving tntPlacedBy;
public int fuse;
public EntityNukePrimed(World gameWorld) {
super(gameWorld);
this.preventEntitySpawning = true;
this.setSize(0.98F, 0.98F);
this.yOffset = this.height / 2.0F;
}
public EntityNukePrimed(World gameWorld, double X, double Y, double Z, EntityLiving entityLiving) {
this(gameWorld);
this.setPosition(X, Y, Z);
float var9 = (float)(Math.random() * (double)((float)Math.PI) * 2.0D);
this.motionX = (double)(-((float)Math.sin((double)var9)) * 0.02F);
this.motionY = (double)0.2F;
this.motionZ = (double)(-((float)Math.cos((double)var9)) * 0.02F);
this.prevPosX = X;
this.prevPosY = Y;
this.prevPosZ = Z;
this.tntPlacedBy = entityLiving;
this.fuse = 200;
}
protected void entityInit() {
}
protected boolean canTriggerWalking() {
return false;
}
public boolean canBeCollidedWith() {
return !this.isDead;
}
public void onUpdate() {
this.prevPosX = this.posX; // get the position and set it
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
this.moveEntity(this.motionX, this.motionY, this.motionZ);
this.motionX *= (double)0.98F;
this.motionY *= (double)0.98F;
this.motionZ *= (double)0.98F;
if (this.onGround) {
this.motionX *= (double)0.7F;
this.motionZ *= (double)0.7F;
this.motionY *= -0.5D;
}
if (this.fuse-- <= 0) {
this.setDead();
if (!this.worldObj.isRemote) {
this.explode();
} else {
this.worldObj.spawnParticle("smoke", this.posX, this.posY + 0.5D, this.posZ , 0.0D, 0.0D, 0.0D);
}
}
}
private void explode() {
float explosionPower = 200.0F;
this.worldObj.createWastedExplosion(this, this.posX, this.posY, this.posZ, explosionPower, true);
}
protected void writeEntityToNBT(NBTTagCompound var1) {
}
protected void readEntityFromNBT(NBTTagCompound var1) {
}
public float getShadowSize() {
return 0.0F;
}
public EntityLiving getTntPlacedBy() {
return this.tntPlacedBy;
}
}