Java Code Examples for cn.nukkit.entity.Entity#getDefaultNBT()
The following examples show how to use
cn.nukkit.entity.Entity#getDefaultNBT() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Level.java From Nukkit with GNU General Public License v3.0 | 6 votes |
public void dropExpOrb(Vector3 source, int exp, Vector3 motion, int delay) { Random rand = ThreadLocalRandom.current(); for (int split : EntityXPOrb.splitIntoOrbSizes(exp)) { CompoundTag nbt = Entity.getDefaultNBT(source, motion == null ? new Vector3( (rand.nextDouble() * 0.2 - 0.1) * 2, rand.nextDouble() * 0.4, (rand.nextDouble() * 0.2 - 0.1) * 2) : motion, rand.nextFloat() * 360f, 0); nbt.putShort("Value", split); nbt.putShort("PickupDelay", delay); Entity entity = Entity.createEntity("XpOrb", this.getChunk(source.getChunkX(), source.getChunkZ()), nbt); if (entity != null) { entity.spawnToAll(); } } }
Example 2
Source File: ProjectileDispenseBehavior.java From Nukkit with GNU General Public License v3.0 | 6 votes |
@Override public void dispense(BlockDispenser source, Item item) { Position dispensePos = Position.fromObject(source.getDispensePosition(), source.getLevel()); CompoundTag nbt = Entity.getDefaultNBT(dispensePos); this.correctNBT(nbt); BlockFace face = source.getFacing(); Entity projectile = Entity.createEntity(getEntityType(), dispensePos.getLevel().getChunk(dispensePos.getFloorX(), dispensePos.getFloorZ()), nbt); if (projectile == null) { return; } projectile.setMotion(new Vector3(face.getXOffset(), face.getYOffset() + 0.1f, face.getZOffset()).multiply(6)); projectile.spawnToAll(); }
Example 3
Source File: ProjectileDispenseBehavior.java From Nukkit with GNU General Public License v3.0 | 6 votes |
@Override public void dispense(BlockDispenser source, Item item) { Position dispensePos = Position.fromObject(source.getDispensePosition(), source.getLevel()); CompoundTag nbt = Entity.getDefaultNBT(dispensePos); this.correctNBT(nbt); BlockFace face = source.getFacing(); Entity projectile = Entity.createEntity(getEntityType(), dispensePos.getLevel().getChunk(dispensePos.getFloorX(), dispensePos.getFloorZ()), nbt); if (projectile == null) { return; } projectile.setMotion(new Vector3(face.getXOffset(), face.getYOffset() + 0.1f, face.getZOffset()).multiply(6)); projectile.spawnToAll(); }