Search in sources :

Example 1 with EntityMinecartChest

use of cn.nukkit.entity.item.EntityMinecartChest 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;
}
Also used : BlockRail(cn.nukkit.block.BlockRail) Rail(cn.nukkit.utils.Rail) EntityMinecartChest(cn.nukkit.entity.item.EntityMinecartChest) FloatTag(cn.nukkit.nbt.tag.FloatTag) DoubleTag(cn.nukkit.nbt.tag.DoubleTag) ListTag(cn.nukkit.nbt.tag.ListTag) BlockRail(cn.nukkit.block.BlockRail) CompoundTag(cn.nukkit.nbt.tag.CompoundTag)

Aggregations

BlockRail (cn.nukkit.block.BlockRail)1 EntityMinecartChest (cn.nukkit.entity.item.EntityMinecartChest)1 CompoundTag (cn.nukkit.nbt.tag.CompoundTag)1 DoubleTag (cn.nukkit.nbt.tag.DoubleTag)1 FloatTag (cn.nukkit.nbt.tag.FloatTag)1 ListTag (cn.nukkit.nbt.tag.ListTag)1 Rail (cn.nukkit.utils.Rail)1