cn.nukkit.entity.projectile.EntityEgg Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of powernukkit Show documentation
Show all versions of powernukkit Show documentation
A Minecraft Bedrock Edition server software implementation made in Java from scratch which supports all new features.
package cn.nukkit.entity.projectile;
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;
@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;
}
public EntityEgg(FullChunk chunk, CompoundTag nbt) {
this(chunk, nbt, null);
}
public EntityEgg(FullChunk chunk, CompoundTag nbt, Entity shootingEntity) {
super(chunk, nbt, shootingEntity);
}
@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;
}
@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));
}
}
}