use of cn.nukkit.entity.item.EntityXPOrb in project Nukkit by Nukkit.
the class Level method dropExpOrb.
public void dropExpOrb(Vector3 source, int exp, Vector3 motion, int delay) {
motion = (motion == null) ? new Vector3(new java.util.Random().nextDouble() * 0.2 - 0.1, 0.2, new java.util.Random().nextDouble() * 0.2 - 0.1) : motion;
CompoundTag nbt = new CompoundTag().putList(new ListTag<DoubleTag>("Pos").add(new DoubleTag("", source.getX())).add(new DoubleTag("", source.getY())).add(new DoubleTag("", source.getZ()))).putList(new ListTag<DoubleTag>("Motion").add(new DoubleTag("", motion.getX())).add(new DoubleTag("", motion.getY())).add(new DoubleTag("", motion.getZ()))).putList(new ListTag<FloatTag>("Rotation").add(new FloatTag("", 0)).add(new FloatTag("", 0)));
Entity entity = new EntityXPOrb(this.getChunk(source.getFloorX() >> 4, source.getFloorZ() >> 4), nbt);
EntityXPOrb xpOrb = (EntityXPOrb) entity;
xpOrb.setExp(exp);
xpOrb.setPickupDelay(delay);
xpOrb.saveNBT();
xpOrb.spawnToAll();
}
Aggregations