use of cn.nukkit.nbt.tag.CompoundTag in project Nukkit by Nukkit.
the class BlockSkull method place.
@Override
public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
switch(face) {
case NORTH:
case SOUTH:
case EAST:
case WEST:
case UP:
this.setDamage(face.getIndex());
break;
case DOWN:
default:
return false;
}
this.getLevel().setBlock(block, this, true, true);
CompoundTag nbt = new CompoundTag().putString("id", BlockEntity.SKULL).putByte("SkullType", item.getDamage()).putInt("x", block.getFloorX()).putInt("y", block.getFloorY()).putInt("z", block.getFloorZ()).putByte("Rot", (int) Math.floor((player.yaw * 16 / 360) + 0.5) & 0x0f);
if (item.hasCustomBlockData()) {
for (Tag aTag : item.getCustomBlockData().getAllTags()) {
nbt.put(aTag.getName(), aTag);
}
}
new BlockEntitySkull(getLevel().getChunk((int) block.x >> 4, (int) block.z >> 4), nbt);
return true;
}
use of cn.nukkit.nbt.tag.CompoundTag in project Nukkit by Nukkit.
the class ItemMinecart method onActivate.
@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;
}
use of cn.nukkit.nbt.tag.CompoundTag in project Nukkit by Nukkit.
the class ItemMinecartChest method onActivate.
@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;
}
use of cn.nukkit.nbt.tag.CompoundTag in project Nukkit by Nukkit.
the class ItemMinecartHopper method onActivate.
@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;
}
use of cn.nukkit.nbt.tag.CompoundTag in project Nukkit by Nukkit.
the class ItemMinecartTNT method onActivate.
@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;
}
Aggregations