cn.nukkit.nbt.tag.FloatTag Java Examples
The following examples show how to use
cn.nukkit.nbt.tag.FloatTag.
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: BlockTNT.java From Nukkit with GNU General Public License v3.0 | 6 votes |
public void prime(int fuse) { this.getLevel().setBlock(this, new BlockAir(), true); double mot = (new NukkitRandom()).nextSignedFloat() * Math.PI * 2; CompoundTag nbt = new CompoundTag() .putList(new ListTag<DoubleTag>("Pos") .add(new DoubleTag("", this.x + 0.5)) .add(new DoubleTag("", this.y)) .add(new DoubleTag("", this.z + 0.5))) .putList(new ListTag<DoubleTag>("Motion") .add(new DoubleTag("", -Math.sin(mot) * 0.02)) .add(new DoubleTag("", 0.2)) .add(new DoubleTag("", -Math.cos(mot) * 0.02))) .putList(new ListTag<FloatTag>("Rotation") .add(new FloatTag("", 0)) .add(new FloatTag("", 0))) .putShort("Fuse", fuse); Entity tnt = new EntityPrimedTNT( this.getLevel().getChunk(this.getFloorX() >> 4, this.getFloorZ() >> 4), nbt ); tnt.spawnToAll(); this.level.addSound(this, Sound.RANDOM_FUSE); }
Example #2
Source File: EntityThrownTrident.java From Nukkit with GNU General Public License v3.0 | 6 votes |
public Entity create(Object type, Position source, Object... args) { FullChunk chunk = source.getLevel().getChunk((int) source.x >> 4, (int) source.z >> 4); if (chunk == null) return null; CompoundTag nbt = new CompoundTag() .putList(new ListTag<DoubleTag>("Pos") .add(new DoubleTag("", source.x + 0.5)) .add(new DoubleTag("", source.y)) .add(new DoubleTag("", source.z + 0.5))) .putList(new ListTag<DoubleTag>("Motion") .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0))) .putList(new ListTag<FloatTag>("Rotation") .add(new FloatTag("", new Random().nextFloat() * 360)) .add(new FloatTag("", 0))); return Entity.createEntity(type.toString(), chunk, nbt, args); }
Example #3
Source File: ItemFirework.java From Nukkit with GNU General Public License v3.0 | 6 votes |
private void spawnFirework(Level level, Vector3 pos) { CompoundTag nbt = new CompoundTag() .putList(new ListTag<DoubleTag>("Pos") .add(new DoubleTag("", pos.x + 0.5)) .add(new DoubleTag("", pos.y + 0.5)) .add(new DoubleTag("", pos.z + 0.5))) .putList(new ListTag<DoubleTag>("Motion") .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0))) .putList(new ListTag<FloatTag>("Rotation") .add(new FloatTag("", 0)) .add(new FloatTag("", 0))) .putCompound("FireworkItem", NBTIO.putItemHelper(this)); EntityFirework entity = (EntityFirework) Entity.createEntity("Firework", level.getChunk(pos.getFloorX() >> 4, pos.getFloorZ() >> 4), nbt); if (entity != null) { entity.spawnToAll(); } }
Example #4
Source File: BlockTNT.java From Nukkit with GNU General Public License v3.0 | 6 votes |
public void prime(int fuse, Entity source) { this.getLevel().setBlock(this, Block.get(BlockID.AIR), true); double mot = (new NukkitRandom()).nextSignedFloat() * Math.PI * 2; CompoundTag nbt = new CompoundTag() .putList(new ListTag<DoubleTag>("Pos") .add(new DoubleTag("", this.x + 0.5)) .add(new DoubleTag("", this.y)) .add(new DoubleTag("", this.z + 0.5))) .putList(new ListTag<DoubleTag>("Motion") .add(new DoubleTag("", -Math.sin(mot) * 0.02)) .add(new DoubleTag("", 0.2)) .add(new DoubleTag("", -Math.cos(mot) * 0.02))) .putList(new ListTag<FloatTag>("Rotation") .add(new FloatTag("", 0)) .add(new FloatTag("", 0))) .putShort("Fuse", fuse); Entity tnt = Entity.createEntity("PrimedTnt", this.getLevel().getChunk(this.getFloorX() >> 4, this.getFloorZ() >> 4), nbt, source ); if(tnt == null) { return; } tnt.spawnToAll(); this.level.addSound(this, Sound.RANDOM_FUSE); }
Example #5
Source File: Entity.java From Nukkit with GNU General Public License v3.0 | 6 votes |
public static CompoundTag getDefaultNBT(Vector3 pos) { Location loc = pos instanceof Location ? (Location) pos : null; return new CompoundTag() .putList(new ListTag<DoubleTag>("Pos") .add(new DoubleTag("", pos.x)) .add(new DoubleTag("", pos.y)) .add(new DoubleTag("", pos.z))) .putList(new ListTag<DoubleTag>("Motion") .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0))) .putList(new ListTag<FloatTag>("Rotation") .add(new FloatTag("", (float) (loc != null ? loc.getYaw() : 0))) .add(new FloatTag("", (float) (loc != null ? loc.getPitch() : 0)))); }
Example #6
Source File: BlockFallable.java From Jupiter with GNU General Public License v3.0 | 6 votes |
public int onUpdate(int type) { if (type == Level.BLOCK_UPDATE_NORMAL) { Block down = this.down(); if (down.getId() == AIR || down instanceof BlockLiquid) { EntityFallingBlock fall = (EntityFallingBlock) Entity.createEntity("FallingSand", this.getLevel().getChunk((int) (this.x) >> 4, (int) (this.z) >> 4), new CompoundTag() .putList(new ListTag<DoubleTag>("Pos") .add(new DoubleTag("", this.x + 0.5)) .add(new DoubleTag("", this.y)) .add(new DoubleTag("", this.z + 0.5))) .putList(new ListTag<DoubleTag>("Motion") .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0))) .putList(new ListTag<FloatTag>("Rotation") .add(new FloatTag("", 0)) .add(new FloatTag("", 0))) .putInt("TileID", this.getId()) .putByte("Data", this.getDamage())); fall.spawnToAll(); } } return type; }
Example #7
Source File: EssentialsAPI.java From EssentialsNK with GNU General Public License v3.0 | 6 votes |
public void strikeLighting(Position pos) { FullChunk chunk = pos.getLevel().getChunk((int) pos.getX() >> 4, (int) pos.getZ() >> 4); CompoundTag nbt = new CompoundTag() .putList(new ListTag<DoubleTag>("Pos") .add(new DoubleTag("", pos.getX())) .add(new DoubleTag("", pos.getY())) .add(new DoubleTag("", pos.getZ()))) .putList(new ListTag<DoubleTag>("Motion") .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0))) .putList(new ListTag<FloatTag>("Rotation") .add(new FloatTag("", 0)) .add(new FloatTag("", 0))); EntityLightning lightning = new EntityLightning(chunk, nbt); lightning.spawnToAll(); }
Example #8
Source File: Level.java From Jupiter with GNU General Public License v3.0 | 6 votes |
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(); }
Example #9
Source File: BlockTNT.java From Jupiter with GNU General Public License v3.0 | 6 votes |
public void prime(int fuse) { this.getLevel().setBlock(this, new BlockAir(), true); double mot = (new NukkitRandom()).nextSignedFloat() * Math.PI * 2; CompoundTag nbt = new CompoundTag() .putList(new ListTag<DoubleTag>("Pos") .add(new DoubleTag("", this.x + 0.5)) .add(new DoubleTag("", this.y)) .add(new DoubleTag("", this.z + 0.5))) .putList(new ListTag<DoubleTag>("Motion") .add(new DoubleTag("", -Math.sin(mot) * 0.02)) .add(new DoubleTag("", 0.2)) .add(new DoubleTag("", -Math.cos(mot) * 0.02))) .putList(new ListTag<FloatTag>("Rotation") .add(new FloatTag("", 0)) .add(new FloatTag("", 0))) .putByte("Fuse", fuse); Entity tnt = new EntityPrimedTNT( this.getLevel().getChunk(this.getFloorX() >> 4, this.getFloorZ() >> 4), nbt ); tnt.spawnToAll(); this.level.addSound(new TNTPrimeSound(this)); }
Example #10
Source File: EntityLiving.java From Jupiter with GNU General Public License v3.0 | 5 votes |
@Override protected void initEntity() { super.initEntity(); if (this.namedTag.contains("HealF")) { this.namedTag.putFloat("Health", this.namedTag.getShort("HealF")); this.namedTag.remove("HealF"); } if (!this.namedTag.contains("Health") || !(this.namedTag.get("Health") instanceof FloatTag)) { this.namedTag.putFloat("Health", this.getMaxHealth()); } this.setHealth(this.namedTag.getFloat("Health")); }
Example #11
Source File: ItemMinecartHopper.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public boolean onActivate(Level level, Player player, Block block, Block target, BlockFace face, double fx, double fy, double fz) { if (Rail.isRailBlock(target)) { Rail.Orientation type = ((BlockRail) target).getOrientation(); double adjacent = 0.0D; if (type.isAscending()) { adjacent = 0.5D; } EntityMinecartHopper minecart = (EntityMinecartHopper) Entity.createEntity("MinecartHopper", level.getChunk(target.getFloorX() >> 4, target.getFloorZ() >> 4), new CompoundTag("") .putList(new ListTag<>("Pos") .add(new DoubleTag("", target.getX() + 0.5)) .add(new DoubleTag("", target.getY() + 0.0625D + adjacent)) .add(new DoubleTag("", target.getZ() + 0.5))) .putList(new ListTag<>("Motion") .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0))) .putList(new ListTag<>("Rotation") .add(new FloatTag("", 0)) .add(new FloatTag("", 0))) ); if(minecart == null) { return false; } if (player.isSurvival()) { Item item = player.getInventory().getItemInHand(); item.setCount(item.getCount() - 1); player.getInventory().setItemInHand(item); } minecart.spawnToAll(); return true; } return false; }
Example #12
Source File: ItemBoat.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public boolean onActivate(Level level, Player player, Block block, Block target, BlockFace face, double fx, double fy, double fz) { if (face != BlockFace.UP) return false; EntityBoat boat = (EntityBoat) Entity.createEntity("Boat", level.getChunk(block.getFloorX() >> 4, block.getFloorZ() >> 4), new CompoundTag("") .putList(new ListTag<DoubleTag>("Pos") .add(new DoubleTag("", block.getX() + 0.5)) .add(new DoubleTag("", block.getY() - (target instanceof BlockWater ? 0.0625 : 0))) .add(new DoubleTag("", block.getZ() + 0.5))) .putList(new ListTag<DoubleTag>("Motion") .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0))) .putList(new ListTag<FloatTag>("Rotation") .add(new FloatTag("", (float) ((player.yaw + 90f) % 360))) .add(new FloatTag("", 0))) .putByte("woodID", this.getDamage()) ); if (boat == null) { return false; } if (player.isSurvival()) { Item item = player.getInventory().getItemInHand(); item.setCount(item.getCount() - 1); player.getInventory().setItemInHand(item); } boat.spawnToAll(); return true; }
Example #13
Source File: ItemEndCrystal.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public boolean onActivate(Level level, Player player, Block block, Block target, BlockFace face, double fx, double fy, double fz) { if (!(target instanceof BlockBedrock) && !(target instanceof BlockObsidian)) return false; FullChunk chunk = level.getChunk((int) block.getX() >> 4, (int) block.getZ() >> 4); if (chunk == null) { return false; } CompoundTag nbt = new CompoundTag() .putList(new ListTag<DoubleTag>("Pos") .add(new DoubleTag("", block.getX() + 0.5)) .add(new DoubleTag("", block.getY())) .add(new DoubleTag("", block.getZ() + 0.5))) .putList(new ListTag<DoubleTag>("Motion") .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0))) .putList(new ListTag<FloatTag>("Rotation") .add(new FloatTag("", new Random().nextFloat() * 360)) .add(new FloatTag("", 0))); if (this.hasCustomName()) { nbt.putString("CustomName", this.getCustomName()); } Entity entity = Entity.createEntity("EndCrystal", chunk, nbt); if (entity != null) { if (player.isSurvival()) { Item item = player.getInventory().getItemInHand(); item.setCount(item.getCount() - 1); player.getInventory().setItemInHand(item); } entity.spawnToAll(); return true; } return false; }
Example #14
Source File: ItemMinecartChest.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public boolean onActivate(Level level, Player player, Block block, Block target, BlockFace face, double fx, double fy, double fz) { if (Rail.isRailBlock(target)) { Rail.Orientation type = ((BlockRail) target).getOrientation(); double adjacent = 0.0D; if (type.isAscending()) { adjacent = 0.5D; } EntityMinecartChest minecart = (EntityMinecartChest) Entity.createEntity("MinecartChest", level.getChunk(target.getFloorX() >> 4, target.getFloorZ() >> 4), new CompoundTag("") .putList(new ListTag<>("Pos") .add(new DoubleTag("", target.getX() + 0.5)) .add(new DoubleTag("", target.getY() + 0.0625D + adjacent)) .add(new DoubleTag("", target.getZ() + 0.5))) .putList(new ListTag<>("Motion") .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0))) .putList(new ListTag<>("Rotation") .add(new FloatTag("", 0)) .add(new FloatTag("", 0))) ); if(minecart == null) { return false; } if (player.isSurvival()) { Item item = player.getInventory().getItemInHand(); item.setCount(item.getCount() - 1); player.getInventory().setItemInHand(item); } minecart.spawnToAll(); return true; } return false; }
Example #15
Source File: ItemMinecart.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public boolean onActivate(Level level, Player player, Block block, Block target, BlockFace face, double fx, double fy, double fz) { if (Rail.isRailBlock(target)) { Rail.Orientation type = ((BlockRail) target).getOrientation(); double adjacent = 0.0D; if (type.isAscending()) { adjacent = 0.5D; } EntityMinecartEmpty minecart = (EntityMinecartEmpty) Entity.createEntity("MinecartRideable", level.getChunk(target.getFloorX() >> 4, target.getFloorZ() >> 4), new CompoundTag("") .putList(new ListTag<>("Pos") .add(new DoubleTag("", target.getX() + 0.5)) .add(new DoubleTag("", target.getY() + 0.0625D + adjacent)) .add(new DoubleTag("", target.getZ() + 0.5))) .putList(new ListTag<>("Motion") .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0))) .putList(new ListTag<>("Rotation") .add(new FloatTag("", 0)) .add(new FloatTag("", 0))) ); if(minecart == null) { return false; } if (player.isSurvival()) { Item item = player.getInventory().getItemInHand(); item.setCount(item.getCount() - 1); player.getInventory().setItemInHand(item); } minecart.spawnToAll(); return true; } return false; }
Example #16
Source File: BlockFallable.java From Nukkit with GNU General Public License v3.0 | 5 votes |
public int onUpdate(int type) { if (type == Level.BLOCK_UPDATE_NORMAL) { Block down = this.down(); if (down.getId() == AIR || down instanceof BlockLiquid || down instanceof BlockFire) { BlockFallEvent event = new BlockFallEvent(this); this.level.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return type; } this.level.setBlock(this, Block.get(Block.AIR), true, true); CompoundTag nbt = new CompoundTag() .putList(new ListTag<DoubleTag>("Pos") .add(new DoubleTag("", this.x + 0.5)) .add(new DoubleTag("", this.y)) .add(new DoubleTag("", this.z + 0.5))) .putList(new ListTag<DoubleTag>("Motion") .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0))) .putList(new ListTag<FloatTag>("Rotation") .add(new FloatTag("", 0)) .add(new FloatTag("", 0))) .putInt("TileID", this.getId()) .putByte("Data", this.getDamage()); EntityFallingBlock fall = (EntityFallingBlock) Entity.createEntity("FallingSand", this.getLevel().getChunk((int) this.x >> 4, (int) this.z >> 4), nbt); if (fall != null) { fall.spawnToAll(); } } } return type; }
Example #17
Source File: EntityLiving.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override protected void initEntity() { super.initEntity(); if (this.namedTag.contains("HealF")) { this.namedTag.putFloat("Health", this.namedTag.getShort("HealF")); this.namedTag.remove("HealF"); } if (!this.namedTag.contains("Health") || !(this.namedTag.get("Health") instanceof FloatTag)) { this.namedTag.putFloat("Health", this.getMaxHealth()); } this.setHealth(this.namedTag.getFloat("Health")); }
Example #18
Source File: ItemMinecartTNT.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public boolean onActivate(Level level, Player player, Block block, Block target, BlockFace face, double fx, double fy, double fz) { if (Rail.isRailBlock(target)) { Rail.Orientation type = ((BlockRail) target).getOrientation(); double adjacent = 0.0D; if (type.isAscending()) { adjacent = 0.5D; } EntityMinecartTNT minecart = new EntityMinecartTNT( level.getChunk(target.getFloorX() >> 4, target.getFloorZ() >> 4), new CompoundTag("") .putList(new ListTag<>("Pos") .add(new DoubleTag("", target.getX() + 0.5)) .add(new DoubleTag("", target.getY() + 0.0625D + adjacent)) .add(new DoubleTag("", target.getZ() + 0.5))) .putList(new ListTag<>("Motion") .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0))) .putList(new ListTag<>("Rotation") .add(new FloatTag("", 0)) .add(new FloatTag("", 0))) ); minecart.spawnToAll(); count -= 1; return true; } return false; }
Example #19
Source File: ProjectileItem.java From Nukkit with GNU General Public License v3.0 | 5 votes |
public boolean onClickAir(Player player, Vector3 directionVector) { CompoundTag nbt = new CompoundTag() .putList(new ListTag<DoubleTag>("Pos") .add(new DoubleTag("", player.x)) .add(new DoubleTag("", player.y + player.getEyeHeight())) .add(new DoubleTag("", player.z))) .putList(new ListTag<DoubleTag>("Motion") .add(new DoubleTag("", directionVector.x)) .add(new DoubleTag("", directionVector.y)) .add(new DoubleTag("", directionVector.z))) .putList(new ListTag<FloatTag>("Rotation") .add(new FloatTag("", (float) player.yaw)) .add(new FloatTag("", (float) player.pitch))); this.correctNBT(nbt); Entity projectile = Entity.createEntity(this.getProjectileEntityType(), player.getLevel().getChunk(player.getFloorX() >> 4, player.getFloorZ() >> 4), nbt, player); if (projectile != null) { projectile.setMotion(projectile.getMotion().multiply(this.getThrowForce())); this.count--; if (projectile instanceof EntityProjectile) { ProjectileLaunchEvent ev = new ProjectileLaunchEvent((EntityProjectile) projectile); player.getServer().getPluginManager().callEvent(ev); if (ev.isCancelled()) { projectile.kill(); } else { projectile.spawnToAll(); player.getLevel().addSound(player, Sound.RANDOM_BOW, 1, 1, player.getViewers().values()); } } else { projectile.spawnToAll(); } } else { return false; } return true; }
Example #20
Source File: ItemMinecartHopper.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public boolean onActivate(Level level, Player player, Block block, Block target, BlockFace face, double fx, double fy, double fz) { if (Rail.isRailBlock(target)) { Rail.Orientation type = ((BlockRail) target).getOrientation(); double adjacent = 0.0D; if (type.isAscending()) { adjacent = 0.5D; } EntityMinecartHopper minecart = new EntityMinecartHopper( level.getChunk(target.getFloorX() >> 4, target.getFloorZ() >> 4), new CompoundTag("") .putList(new ListTag<>("Pos") .add(new DoubleTag("", target.getX() + 0.5)) .add(new DoubleTag("", target.getY() + 0.0625D + adjacent)) .add(new DoubleTag("", target.getZ() + 0.5))) .putList(new ListTag<>("Motion") .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0))) .putList(new ListTag<>("Rotation") .add(new FloatTag("", 0)) .add(new FloatTag("", 0))) ); minecart.spawnToAll(); count -= 1; return true; } return false; }
Example #21
Source File: ItemSpawnEgg.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public boolean onActivate(Level level, Player player, Block block, Block target, BlockFace face, double fx, double fy, double fz) { FullChunk chunk = level.getChunk((int) block.getX() >> 4, (int) block.getZ() >> 4); if (chunk == null) { return false; } CompoundTag nbt = new CompoundTag() .putList(new ListTag<DoubleTag>("Pos") .add(new DoubleTag("", block.getX() + 0.5)) .add(new DoubleTag("", block.getY())) .add(new DoubleTag("", block.getZ() + 0.5))) .putList(new ListTag<DoubleTag>("Motion") .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0))) .putList(new ListTag<FloatTag>("Rotation") .add(new FloatTag("", new Random().nextFloat() * 360)) .add(new FloatTag("", 0))); if (this.hasCustomName()) { nbt.putString("CustomName", this.getCustomName()); } Entity entity = Entity.createEntity(this.meta, chunk, nbt); if (entity != null) { if (player.isSurvival()) { Item item = player.getInventory().getItemInHand(); item.setCount(item.getCount() - 1); player.getInventory().setItemInHand(item); } entity.spawnToAll(); return true; } return false; }
Example #22
Source File: ItemBoat.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public boolean onActivate(Level level, Player player, Block block, Block target, BlockFace face, double fx, double fy, double fz) { if (face != BlockFace.UP) return false; EntityBoat boat = new EntityBoat( level.getChunk(block.getFloorX() >> 4, block.getFloorZ() >> 4), new CompoundTag("") .putList(new ListTag<DoubleTag>("Pos") .add(new DoubleTag("", block.getX() + 0.5)) .add(new DoubleTag("", block.getY() - 0.0625)) .add(new DoubleTag("", block.getZ() + 0.5))) .putList(new ListTag<DoubleTag>("Motion") .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0))) .putList(new ListTag<FloatTag>("Rotation") .add(new FloatTag("", (float) ((player.yaw + 90f) % 360))) .add(new FloatTag("", 0))) .putByte("woodID", this.getDamage()) ); if (player.isSurvival()) { Item item = player.getInventory().getItemInHand(); item.setCount(item.getCount() - 1); player.getInventory().setItemInHand(item); } boat.spawnToAll(); return true; }
Example #23
Source File: ItemMinecartChest.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public boolean onActivate(Level level, Player player, Block block, Block target, BlockFace face, double fx, double fy, double fz) { if (Rail.isRailBlock(target)) { Rail.Orientation type = ((BlockRail) target).getOrientation(); double adjacent = 0.0D; if (type.isAscending()) { adjacent = 0.5D; } EntityMinecartChest minecart = new EntityMinecartChest( level.getChunk(target.getFloorX() >> 4, target.getFloorZ() >> 4), new CompoundTag("") .putList(new ListTag<>("Pos") .add(new DoubleTag("", target.getX() + 0.5)) .add(new DoubleTag("", target.getY() + 0.0625D + adjacent)) .add(new DoubleTag("", target.getZ() + 0.5))) .putList(new ListTag<>("Motion") .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0))) .putList(new ListTag<>("Rotation") .add(new FloatTag("", 0)) .add(new FloatTag("", 0))) ); minecart.spawnToAll(); count -= 1; return true; } return false; }
Example #24
Source File: ItemMinecart.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public boolean onActivate(Level level, Player player, Block block, Block target, BlockFace face, double fx, double fy, double fz) { if (Rail.isRailBlock(target)) { Rail.Orientation type = ((BlockRail) target).getOrientation(); double adjacent = 0.0D; if (type.isAscending()) { adjacent = 0.5D; } EntityMinecartEmpty minecart = new EntityMinecartEmpty( level.getChunk(target.getFloorX() >> 4, target.getFloorZ() >> 4), new CompoundTag("") .putList(new ListTag<>("Pos") .add(new DoubleTag("", target.getX() + 0.5)) .add(new DoubleTag("", target.getY() + 0.0625D + adjacent)) .add(new DoubleTag("", target.getZ() + 0.5))) .putList(new ListTag<>("Motion") .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0))) .putList(new ListTag<>("Rotation") .add(new FloatTag("", 0)) .add(new FloatTag("", 0))) ); minecart.spawnToAll(); count -= 1; return true; } return false; }
Example #25
Source File: BlockFallable.java From Nukkit with GNU General Public License v3.0 | 5 votes |
public int onUpdate(int type) { if (type == Level.BLOCK_UPDATE_NORMAL) { Block down = this.down(); if (down.getId() == AIR || down instanceof BlockLiquid) { this.level.setBlock(this, Block.get(Block.AIR), true, true); CompoundTag nbt = new CompoundTag() .putList(new ListTag<DoubleTag>("Pos") .add(new DoubleTag("", this.x + 0.5)) .add(new DoubleTag("", this.y)) .add(new DoubleTag("", this.z + 0.5))) .putList(new ListTag<DoubleTag>("Motion") .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0))) .putList(new ListTag<FloatTag>("Rotation") .add(new FloatTag("", 0)) .add(new FloatTag("", 0))) .putInt("TileID", this.getId()) .putByte("Data", this.getDamage()); EntityFallingBlock fall = new EntityFallingBlock(this.getLevel().getChunk((int) this.x >> 4, (int) this.z >> 4), nbt); fall.spawnToAll(); } } return type; }
Example #26
Source File: SummonCommand.java From Jupiter with GNU General Public License v3.0 | 5 votes |
@Override public boolean execute(CommandSender sender, String commandLabel, String[] args) { if (!this.testPermission(sender)) { return true; } if (sender instanceof ConsoleCommandSender) { sender.sendMessage(new TranslationContainer("commands.generic.ingame")); return true; } if (args.length < 2) { sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage)); return false; } Position pos = new Position(Double.parseDouble(args[1]), Double.parseDouble(args[2]), Double.parseDouble(args[3]), ((Player) sender).getLevel()); CompoundTag nbt = new CompoundTag() .putList(new ListTag<DoubleTag>("Pos") .add(new DoubleTag("", pos.getX() + 0.5)) .add(new DoubleTag("", pos.getY())) .add(new DoubleTag("", pos.getZ() + 0.5))) .putList(new ListTag<DoubleTag>("Motion") .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0))) .putList(new ListTag<FloatTag>("Rotation") .add(new FloatTag("", new Random().nextFloat() * 360)) .add(new FloatTag("", 0))); Entity entity = Entity.createEntity(args[0], pos.getLevel().getChunk((int) pos.getX() >> 4, (int) pos.getZ() >> 4, true), nbt); entity.spawnToAll(); return true; }
Example #27
Source File: ItemMinecartHopper.java From Jupiter with GNU General Public License v3.0 | 5 votes |
@Override public boolean onActivate(Level level, Player player, Block block, Block target, BlockFace face, double fx, double fy, double fz) { if (Rail.isRailBlock(target)) { Rail.Orientation type = ((BlockRail) target).getOrientation(); double adjacent = 0.0D; if (type.isAscending()) { adjacent = 0.5D; } EntityMinecartHopper minecart = new EntityMinecartHopper( level.getChunk(target.getFloorX() >> 4, target.getFloorZ() >> 4), new CompoundTag("") .putList(new ListTag<>("Pos") .add(new DoubleTag("", target.getX() + 0.5)) .add(new DoubleTag("", target.getY() + 0.0625D + adjacent)) .add(new DoubleTag("", target.getZ() + 0.5))) .putList(new ListTag<>("Motion") .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0))) .putList(new ListTag<>("Rotation") .add(new FloatTag("", 0)) .add(new FloatTag("", 0))) ); minecart.spawnToAll(); count -= 1; return true; } return false; }
Example #28
Source File: ItemSpawnEgg.java From Jupiter with GNU General Public License v3.0 | 5 votes |
@Override public boolean onActivate(Level level, Player player, Block block, Block target, BlockFace face, double fx, double fy, double fz) { FullChunk chunk = level.getChunk((int) block.getX() >> 4, (int) block.getZ() >> 4); if (chunk == null) { return false; } CompoundTag nbt = new CompoundTag() .putList(new ListTag<DoubleTag>("Pos") .add(new DoubleTag("", block.getX() + 0.5)) .add(new DoubleTag("", block.getY())) .add(new DoubleTag("", block.getZ() + 0.5))) .putList(new ListTag<DoubleTag>("Motion") .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0))) .putList(new ListTag<FloatTag>("Rotation") .add(new FloatTag("", new Random().nextFloat() * 360)) .add(new FloatTag("", 0))); if (this.hasCustomName()) { nbt.putString("CustomName", this.getCustomName()); } Entity entity = Entity.createEntity(this.meta, chunk, nbt); if (entity != null) { if (player.isSurvival()) { Item item = player.getInventory().getItemInHand(); item.setCount(item.getCount() - 1); player.getInventory().setItemInHand(item); } entity.spawnToAll(); return true; } return false; }
Example #29
Source File: ItemBoat.java From Jupiter with GNU General Public License v3.0 | 5 votes |
@Override public boolean onActivate(Level level, Player player, Block block, Block target, BlockFace face, double fx, double fy, double fz) { if (face != BlockFace.UP) return false; EntityBoat boat = new EntityBoat( level.getChunk(block.getFloorX() >> 4, block.getFloorZ() >> 4), new CompoundTag("") .putList(new ListTag<DoubleTag>("Pos") .add(new DoubleTag("", block.getX() + 0.5)) .add(new DoubleTag("", block.getY() - 0.0625)) .add(new DoubleTag("", block.getZ() + 0.5))) .putList(new ListTag<DoubleTag>("Motion") .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0))) .putList(new ListTag<FloatTag>("Rotation") .add(new FloatTag("", (float) ((player.yaw + 90f) % 360))) .add(new FloatTag("", 0))) .putByte("woodID", this.getDamage()) ); if (player.isSurvival()) { Item item = player.getInventory().getItemInHand(); item.setCount(item.getCount() - 1); player.getInventory().setItemInHand(item); } boat.spawnToAll(); return true; }
Example #30
Source File: ItemMinecartChest.java From Jupiter with GNU General Public License v3.0 | 5 votes |
@Override public boolean onActivate(Level level, Player player, Block block, Block target, BlockFace face, double fx, double fy, double fz) { if (Rail.isRailBlock(target)) { Rail.Orientation type = ((BlockRail) target).getOrientation(); double adjacent = 0.0D; if (type.isAscending()) { adjacent = 0.5D; } EntityMinecartChest minecart = new EntityMinecartChest( level.getChunk(target.getFloorX() >> 4, target.getFloorZ() >> 4), new CompoundTag("") .putList(new ListTag<>("Pos") .add(new DoubleTag("", target.getX() + 0.5)) .add(new DoubleTag("", target.getY() + 0.0625D + adjacent)) .add(new DoubleTag("", target.getZ() + 0.5))) .putList(new ListTag<>("Motion") .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0))) .putList(new ListTag<>("Rotation") .add(new FloatTag("", 0)) .add(new FloatTag("", 0))) ); minecart.spawnToAll(); count -= 1; return true; } return false; }