cn.nukkit.entity.projectile.EntityEgg Maven / Gradle / Ivy
package cn.nukkit.entity.projectile;
import cn.nukkit.api.PowerNukkitOnly;
import cn.nukkit.api.Since;
import cn.nukkit.entity.Entity;
import cn.nukkit.item.ItemEgg;
import cn.nukkit.level.format.FullChunk;
import cn.nukkit.level.particle.ItemBreakParticle;
import cn.nukkit.nbt.tag.CompoundTag;
import java.util.concurrent.ThreadLocalRandom;
/**
* @author MagicDroidX (Nukkit Project)
*/
public class EntityEgg extends EntityProjectile {
public static final int NETWORK_ID = 82;
public EntityEgg(FullChunk chunk, CompoundTag nbt) {
this(chunk, nbt, null);
}
public EntityEgg(FullChunk chunk, CompoundTag nbt, Entity shootingEntity) {
super(chunk, nbt, shootingEntity);
}
@Override
public int getNetworkId() {
return NETWORK_ID;
}
@Override
public float getWidth() {
return 0.25f;
}
@Override
public float getLength() {
return 0.25f;
}
@Override
public float getHeight() {
return 0.25f;
}
@Override
protected float getGravity() {
return 0.03f;
}
@Override
protected float getDrag() {
return 0.01f;
}
@Override
public boolean onUpdate(int currentTick) {
if (this.closed) {
return false;
}
boolean hasUpdate = super.onUpdate(currentTick);
if (this.age > 1200 || this.isCollided) {
this.kill();
hasUpdate = true;
}
return hasUpdate;
}
@PowerNukkitOnly
@Override
protected void addHitEffect() {
int particles = ThreadLocalRandom.current().nextInt(10) + 5;
ItemEgg egg = new ItemEgg();
for (int i = 0; i < particles; i++) {
level.addParticle(new ItemBreakParticle(this, egg));
}
}
@PowerNukkitOnly
@Since("1.5.1.0-PN")
@Override
public String getOriginalName() {
return "Egg";
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy