tcr/java/src/game/entity/item/EntityExplosion.java
2025-03-26 15:43:58 +01:00

97 lines
2.2 KiB
Java
Executable file

package game.entity.item;
import game.entity.Entity;
import game.entity.EntityType;
import game.nbt.NBTTagCompound;
import game.world.Explosion;
import game.world.World;
public class EntityExplosion extends Entity
{
private int progress;
private int radius;
public EntityExplosion(World worldIn)
{
super(worldIn);
this.preventSpawning = true;
this.setSize(0.1F, 0.1F);
// this.setInvisible(true);
}
public EntityExplosion(World worldIn, double x, double y, double z)
{
this(worldIn, x, y, z, 70);
}
public EntityExplosion(World worldIn, double x, double y, double z, int radius)
{
this(worldIn);
this.setPosition(x, y, z);
this.prevX = x;
this.prevY = y;
this.prevZ = z;
this.radius = radius;
}
protected void entityInit()
{
}
protected boolean canTriggerWalking()
{
return false;
}
public void onUpdate()
{
this.prevX = this.posX;
this.prevY = this.posY;
this.prevZ = this.posZ;
this.motionX = this.motionY = this.motionZ = 0.0D;
if(this.progress++ >= this.radius) {
this.setDead();
}
else if(!this.worldObj.client) {
this.explode(this.progress - 1);
}
}
private void explode(double min)
{
Explosion.doExplosionAlgo3(this.worldObj, this.posX, this.posY + (double)(this.height / 2.0F), this.posZ, this.rand, min + 6.0d, min);
}
protected void writeEntityToNBT(NBTTagCompound tagCompound)
{
tagCompound.setInteger("Progress", this.progress);
tagCompound.setInteger("Radius", this.radius);
}
protected void readEntityFromNBT(NBTTagCompound tagCompund)
{
this.progress = tagCompund.getInteger("Progress");
this.radius = tagCompund.getInteger("Radius");
}
public float getEyeHeight()
{
return 0.0F;
}
public int getTrackingRange() {
return 0;
}
public int getUpdateFrequency() {
return 0;
}
public boolean isSendingVeloUpdates() {
return false;
}
public EntityType getType() {
return EntityType.EXPLOSIVE;
}
}