Search in sources :

Example 1 with RedstoneWire

use of org.bukkit.block.data.type.RedstoneWire in project Denizen-For-Bukkit by DenizenScript.

the class FullBlockData method rotateOne.

public FullBlockData rotateOne() {
    if (data instanceof Orientable) {
        BlockData newData = data.clone();
        switch(((Orientable) data).getAxis()) {
            case X:
                ((Orientable) newData).setAxis(Axis.Z);
                break;
            case Z:
                ((Orientable) newData).setAxis(Axis.X);
                break;
        }
        return new FullBlockData(newData, tileEntityData, flags);
    } else if (data instanceof Rotatable) {
        BlockData newData = data.clone();
        ((Rotatable) newData).setRotation(rotateFaceOne(((Rotatable) data).getRotation()));
        return new FullBlockData(newData, tileEntityData, flags);
    } else if (data instanceof Directional) {
        BlockData newData = data.clone();
        ((Directional) newData).setFacing(rotateFaceOne(((Directional) data).getFacing()));
        return new FullBlockData(newData, tileEntityData, flags);
    } else if (data instanceof Rail) {
        BlockData newData = data.clone();
        ((Rail) newData).setShape(rotateRailShapeOne(((Rail) data).getShape()));
        return new FullBlockData(newData, tileEntityData, flags);
    } else if (data instanceof MultipleFacing) {
        MultipleFacing newData = (MultipleFacing) data.clone();
        for (BlockFace face : ((MultipleFacing) data).getFaces()) {
            newData.setFace(face, false);
        }
        for (BlockFace face : ((MultipleFacing) data).getFaces()) {
            newData.setFace(rotateFaceOne(face), true);
        }
        return new FullBlockData(newData, tileEntityData, flags);
    } else if (data instanceof RedstoneWire) {
        RedstoneWire newData = (RedstoneWire) data.clone();
        newData.setFace(BlockFace.NORTH, ((RedstoneWire) data).getFace(BlockFace.EAST));
        newData.setFace(BlockFace.WEST, ((RedstoneWire) data).getFace(BlockFace.NORTH));
        newData.setFace(BlockFace.EAST, ((RedstoneWire) data).getFace(BlockFace.SOUTH));
        newData.setFace(BlockFace.SOUTH, ((RedstoneWire) data).getFace(BlockFace.WEST));
        return new FullBlockData(newData, tileEntityData, flags);
    } else if (data instanceof Wall) {
        Wall newData = (Wall) data.clone();
        newData.setHeight(BlockFace.NORTH, ((Wall) data).getHeight(BlockFace.EAST));
        newData.setHeight(BlockFace.WEST, ((Wall) data).getHeight(BlockFace.NORTH));
        newData.setHeight(BlockFace.EAST, ((Wall) data).getHeight(BlockFace.SOUTH));
        newData.setHeight(BlockFace.SOUTH, ((Wall) data).getHeight(BlockFace.WEST));
        return new FullBlockData(newData, tileEntityData, flags);
    }
    return this;
}
Also used : RedstoneWire(org.bukkit.block.data.type.RedstoneWire) Wall(org.bukkit.block.data.type.Wall) BlockFace(org.bukkit.block.BlockFace)

Example 2 with RedstoneWire

use of org.bukkit.block.data.type.RedstoneWire in project Denizen-For-Bukkit by DenizenScript.

the class MaterialSides method adjust.

@Override
public void adjust(Mechanism mechanism) {
    // -->
    if ((mechanism.matches("sides") || mechanism.matches("heights")) && mechanism.requireObject(ListTag.class)) {
        ListTag list = mechanism.valueAsType(ListTag.class);
        if (isWall()) {
            if (list.size() != 5) {
                mechanism.echoError("Invalid sides list, size must be 5.");
                return;
            }
            Wall wall = getWall();
            wall.setHeight(BlockFace.NORTH, Wall.Height.valueOf(list.get(0).toUpperCase()));
            wall.setHeight(BlockFace.EAST, Wall.Height.valueOf(list.get(1).toUpperCase()));
            wall.setHeight(BlockFace.SOUTH, Wall.Height.valueOf(list.get(2).toUpperCase()));
            wall.setHeight(BlockFace.WEST, Wall.Height.valueOf(list.get(3).toUpperCase()));
            wall.setUp(list.get(4).toUpperCase().equals("TALL"));
        } else if (isWire()) {
            if (list.size() != 4) {
                mechanism.echoError("Invalid sides list, size must be 4.");
                return;
            }
            RedstoneWire wire = getWire();
            wire.setFace(BlockFace.NORTH, RedstoneWire.Connection.valueOf(list.get(0).toUpperCase()));
            wire.setFace(BlockFace.EAST, RedstoneWire.Connection.valueOf(list.get(1).toUpperCase()));
            wire.setFace(BlockFace.SOUTH, RedstoneWire.Connection.valueOf(list.get(2).toUpperCase()));
            wire.setFace(BlockFace.WEST, RedstoneWire.Connection.valueOf(list.get(3).toUpperCase()));
        }
    }
}
Also used : RedstoneWire(org.bukkit.block.data.type.RedstoneWire) Wall(org.bukkit.block.data.type.Wall) ListTag(com.denizenscript.denizencore.objects.core.ListTag)

Example 3 with RedstoneWire

use of org.bukkit.block.data.type.RedstoneWire in project Denizen-For-Bukkit by DenizenScript.

the class MaterialSides method getSidesList.

public ListTag getSidesList() {
    ListTag list = new ListTag(5);
    if (isWall()) {
        Wall wall = getWall();
        list.add(wall.getHeight(BlockFace.NORTH).name());
        list.add(wall.getHeight(BlockFace.EAST).name());
        list.add(wall.getHeight(BlockFace.SOUTH).name());
        list.add(wall.getHeight(BlockFace.WEST).name());
        list.add(wall.isUp() ? "TALL" : "NONE");
    } else if (isWire()) {
        RedstoneWire wire = getWire();
        list.add(wire.getFace(BlockFace.NORTH).name());
        list.add(wire.getFace(BlockFace.EAST).name());
        list.add(wire.getFace(BlockFace.SOUTH).name());
        list.add(wire.getFace(BlockFace.WEST).name());
    }
    return list;
}
Also used : RedstoneWire(org.bukkit.block.data.type.RedstoneWire) Wall(org.bukkit.block.data.type.Wall) ListTag(com.denizenscript.denizencore.objects.core.ListTag)

Example 4 with RedstoneWire

use of org.bukkit.block.data.type.RedstoneWire in project Denizen-For-Bukkit by DenizenScript.

the class MaterialSides method describes.

public static boolean describes(ObjectTag material) {
    if (!(material instanceof MaterialTag)) {
        return false;
    }
    MaterialTag mat = (MaterialTag) material;
    if (!mat.hasModernData()) {
        return false;
    }
    BlockData data = mat.getModernData();
    if (!(data instanceof Wall) && !(data instanceof RedstoneWire)) {
        return false;
    }
    return true;
}
Also used : MaterialTag(com.denizenscript.denizen.objects.MaterialTag) RedstoneWire(org.bukkit.block.data.type.RedstoneWire) Wall(org.bukkit.block.data.type.Wall)

Aggregations

RedstoneWire (org.bukkit.block.data.type.RedstoneWire)4 Wall (org.bukkit.block.data.type.Wall)4 ListTag (com.denizenscript.denizencore.objects.core.ListTag)2 MaterialTag (com.denizenscript.denizen.objects.MaterialTag)1 BlockFace (org.bukkit.block.BlockFace)1