Java Code Examples for org.bukkit.block.BlockFace#SOUTH

The following examples show how to use org.bukkit.block.BlockFace#SOUTH . 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: Skull.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
public BlockFace getFacing() {
    int data = getData();

    switch (data) {
        case 0x1:
        default:
            return BlockFace.SELF;

        case 0x2:
            return BlockFace.NORTH;

        case 0x3:
            return BlockFace.SOUTH;

        case 0x4:
            return BlockFace.WEST;

        case 0x5:
            return BlockFace.EAST;
    }
}
 
Example 2
Source File: Recipes.java    From ProRecipes with GNU General Public License v2.0 6 votes vote down vote up
public boolean multiTable(Block b){
	if(b.getRelative(BlockFace.DOWN).getType().equals(Material.AIR))return false;
	
	for(BlockFace f : new BlockFace[]{BlockFace.NORTH, BlockFace.WEST, BlockFace.SOUTH, BlockFace.EAST}){
		
		Block signP = b.getRelative(BlockFace.DOWN).getRelative(f);
		if(signP.getType().equals(Material.SIGN) || 
				signP.getType().equals(MinecraftVersion.getMaterial("SIGN_POST","WALL_SIGN")) || signP.getType().equals(Material.WALL_SIGN)){
			org.bukkit.block.Sign s = (org.bukkit.block.Sign) b.getRelative(BlockFace.DOWN).getRelative(f).getState();
			if(s.getLine(1).equalsIgnoreCase(ProRecipes.getPlugin().ms.getMessage("Multi_Craft", ChatColor.GOLD + "Multi-Craft"))){
				return true;
			}
		}
	}
	return false;
}
 
Example 3
Source File: Bed.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Get the direction that this bed's head is facing toward
 *
 * @return the direction the head of the bed is facing
 */
public BlockFace getFacing() {
    byte data = (byte) (getData() & 0x7);

    switch (data) {
        case 0x0:
            return BlockFace.SOUTH;

        case 0x1:
            return BlockFace.WEST;

        case 0x2:
            return BlockFace.NORTH;

        case 0x3:
        default:
            return BlockFace.EAST;
    }
}
 
Example 4
Source File: PistonExtensionMaterial.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
public BlockFace getFacing() {
    byte dir = (byte) (getData() & 7);

    switch (dir) {
        case 0:
            return BlockFace.DOWN;
        case 1:
            return BlockFace.UP;
        case 2:
            return BlockFace.NORTH;
        case 3:
            return BlockFace.SOUTH;
        case 4:
            return BlockFace.WEST;
        case 5:
            return BlockFace.EAST;
        default:
            return BlockFace.SELF;
    }
}
 
Example 5
Source File: DirectionalContainer.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
public BlockFace getFacing() {
    byte data = getData();

    switch (data) {
        case 0x2:
            return BlockFace.NORTH;

        case 0x3:
            return BlockFace.SOUTH;

        case 0x4:
            return BlockFace.WEST;

        case 0x5:
        default:
            return BlockFace.EAST;
    }
}
 
Example 6
Source File: LWC.java    From Modern-LWC with MIT License 6 votes vote down vote up
/**
 * Find a protection that is adjacent to another block on any of the block's 6
 * sides
 *
 * @param block
 * @param ignore
 * @return
 */
public List<Protection> findAdjacentProtectionsOnAllSides(Block block, Block... ignore) {
    BlockFace[] faces = new BlockFace[]{BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST,
            BlockFace.UP, BlockFace.DOWN};
    List<Block> ignoreList = Arrays.asList(ignore);
    List<Protection> found = new ArrayList<Protection>();

    for (BlockFace face : faces) {
        Protection protection;
        Block adjacentBlock = block.getRelative(face);

        if (!ignoreList.contains(adjacentBlock.getLocation())
                && (protection = findProtection(adjacentBlock.getLocation())) != null) {
            found.add(protection);
        }
    }

    return found;
}
 
Example 7
Source File: PistonBaseMaterial.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
@Override
public BlockFace getFacing() {
    byte dir = (byte) (getData() & 7);

    switch (dir) {
        case 0:
            return BlockFace.DOWN;
        case 1:
            return BlockFace.UP;
        case 2:
            return BlockFace.NORTH;
        case 3:
            return BlockFace.SOUTH;
        case 4:
            return BlockFace.WEST;
        case 5:
            return BlockFace.EAST;
        default:
            return BlockFace.SELF;
    }
}
 
Example 8
Source File: QuadCrateSession.java    From Crazy-Crates with MIT License 6 votes vote down vote up
private void rotateChest(Block chest, Integer direction) {
    BlockFace blockFace;
    switch (direction) {
        case 0://East
            blockFace = BlockFace.WEST;
            break;
        case 1://South
            blockFace = BlockFace.NORTH;
            break;
        case 2://West
            blockFace = BlockFace.EAST;
            break;
        case 3://North
            blockFace = BlockFace.SOUTH;
            break;
        default:
            blockFace = BlockFace.DOWN;
            break;
    }
    BlockState state = chest.getState();
    state.setData(new Chest(blockFace));
    state.update();
}
 
Example 9
Source File: DoubleChestMatcher.java    From Modern-LWC with MIT License 6 votes vote down vote up
public static BlockFace getNeighboringChestBlockFace(Chest chest) {
    if (chest.getType() == Chest.Type.SINGLE)
        return null;
    BlockFace face = chest.getFacing();
    switch (face) {
        case NORTH:
            return chest.getType() == Chest.Type.LEFT ? BlockFace.EAST : BlockFace.WEST;
        case SOUTH:
            return chest.getType() == Chest.Type.LEFT ? BlockFace.WEST : BlockFace.EAST;
        case EAST:
            return chest.getType() == Chest.Type.LEFT ? BlockFace.SOUTH : BlockFace.NORTH;
        case WEST:
            return chest.getType() == Chest.Type.LEFT ? BlockFace.NORTH : BlockFace.SOUTH;
        default:
            return null;
    }
}
 
Example 10
Source File: Comparator.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Gets the direction this comparator is facing
 *
 * @return The direction this comparator is facing
 * @see BlockFace
 */
@Override
public BlockFace getFacing() {
    byte data = (byte) (getData() & 0x3);

    switch (data) {
        case 0x0:
        default:
            return BlockFace.NORTH;

        case 0x1:
            return BlockFace.EAST;

        case 0x2:
            return BlockFace.SOUTH;

        case 0x3:
            return BlockFace.WEST;
    }
}
 
Example 11
Source File: Gate.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
public BlockFace getFacing() {
    switch (getData() & DIR_BIT) {
        case GATE_SOUTH:
            return BlockFace.EAST;
        case GATE_WEST:
            return BlockFace.SOUTH;
        case GATE_NORTH:
            return BlockFace.WEST;
        case GATE_EAST:
            return BlockFace.NORTH;
    }

    return BlockFace.EAST;
}
 
Example 12
Source File: Rails.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @return the direction these tracks are set
 * <p>
 * Note that tracks are bidirectional and that the direction returned
 * is the ascending direction if the track is set on a slope. If it is
 * set as a curve, the corner of the track is returned.
 */
public BlockFace getDirection() {
    byte d = getConvertedData();

    switch (d) {
        case 0x0:
        default:
            return BlockFace.SOUTH;

        case 0x1:
            return BlockFace.EAST;

        case 0x2:
            return BlockFace.EAST;

        case 0x3:
            return BlockFace.WEST;

        case 0x4:
            return BlockFace.NORTH;

        case 0x5:
            return BlockFace.SOUTH;

        case 0x6:
            return BlockFace.NORTH_WEST;

        case 0x7:
            return BlockFace.NORTH_EAST;

        case 0x8:
            return BlockFace.SOUTH_EAST;

        case 0x9:
            return BlockFace.SOUTH_WEST;
    }
}
 
Example 13
Source File: WallMatcher.java    From Modern-LWC with MIT License 5 votes vote down vote up
/**
 * Try and match a wall block
 *
 * @param block
 * @param matchingFace
 * @return
 */
private Block tryMatchBlock(Block block, BlockFace matchingFace) {
    byte direction = block.getData();
    BlockData blockData = block.getBlockData();

    // Blocks such as wall signs or banners
    if (PROTECTABLES_WALL.contains(block.getType()) && blockData instanceof Directional) {
        if (((Directional) block.getState().getBlockData()).getFacing() == matchingFace) {
            return block;
        }
    }

    // Levers, buttons
    else if (PROTECTABLES_LEVERS_ET_AL.contains(block.getType())) {
        byte EAST = 0x4;
        byte WEST = 0x3;
        byte SOUTH = 0x1;
        byte NORTH = 0x2;

        if (matchingFace == BlockFace.EAST && (direction & EAST) == EAST) {
            return block;
        } else if (matchingFace == BlockFace.WEST && (direction & WEST) == WEST) {
            return block;
        } else if (matchingFace == BlockFace.SOUTH && (direction & SOUTH) == SOUTH) {
            return block;
        } else if (matchingFace == BlockFace.NORTH && (direction & NORTH) == NORTH) {
            return block;
        }
    }

    return null;
}
 
Example 14
Source File: RandomUtils.java    From UhcCore with GNU General Public License v3.0 5 votes vote down vote up
public static BlockFace randomAdjacentFace(){
	BlockFace[] faces = new BlockFace[]{
		BlockFace.DOWN,
		BlockFace.UP,
		BlockFace.EAST,
		BlockFace.WEST,
		BlockFace.NORTH,
		BlockFace.SOUTH
	};
	return faces[randomInteger(0,faces.length-1)];
}
 
Example 15
Source File: TripwireHook.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
public BlockFace getAttachedFace() {
    switch (getData() & 0x3) {
        case 0:
            return BlockFace.NORTH;
        case 1:
            return BlockFace.EAST;
        case 2:
            return BlockFace.SOUTH;
        case 3:
            return BlockFace.WEST;
    }
    return null;
}
 
Example 16
Source File: CocoaPlant.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
public BlockFace getFacing() {
    switch (getData() & 0x3) {
        case 0:
            return BlockFace.SOUTH;
        case 1:
            return BlockFace.WEST;
        case 2:
            return BlockFace.NORTH;
        case 3:
            return BlockFace.EAST;
    }
    return null;
}
 
Example 17
Source File: BlockIterator.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
private BlockFace getZFace(Vector direction) {
    return ((direction.getZ() > 0) ? BlockFace.SOUTH : BlockFace.NORTH);
}
 
Example 18
Source File: Sign.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Gets the direction that this sign is currently facing
 *
 * @return BlockFace indicating where this sign is facing
 */
public BlockFace getFacing() {
    byte data = getData();

    if (!isWallSign()) {
        switch (data) {
            case 0x0:
                return BlockFace.SOUTH;

            case 0x1:
                return BlockFace.SOUTH_SOUTH_WEST;

            case 0x2:
                return BlockFace.SOUTH_WEST;

            case 0x3:
                return BlockFace.WEST_SOUTH_WEST;

            case 0x4:
                return BlockFace.WEST;

            case 0x5:
                return BlockFace.WEST_NORTH_WEST;

            case 0x6:
                return BlockFace.NORTH_WEST;

            case 0x7:
                return BlockFace.NORTH_NORTH_WEST;

            case 0x8:
                return BlockFace.NORTH;

            case 0x9:
                return BlockFace.NORTH_NORTH_EAST;

            case 0xA:
                return BlockFace.NORTH_EAST;

            case 0xB:
                return BlockFace.EAST_NORTH_EAST;

            case 0xC:
                return BlockFace.EAST;

            case 0xD:
                return BlockFace.EAST_SOUTH_EAST;

            case 0xE:
                return BlockFace.SOUTH_EAST;

            case 0xF:
                return BlockFace.SOUTH_SOUTH_EAST;
        }

        return null;
    } else {
        return getAttachedFace().getOppositeFace();
    }
}
 
Example 19
Source File: Schematic.java    From ExoticGarden with GNU General Public License v3.0 4 votes vote down vote up
public static void pasteSchematic(Location loc, Tree tree) {
    Schematic schematic;

    try {
        schematic = tree.getSchematic();
    }
    catch (IOException e) {
        ExoticGarden.instance.getLogger().log(Level.WARNING, "Could not paste Schematic for Tree: " + tree.getFruitID() + "_TREE (" + e.getClass().getSimpleName() + ')', e);
        return;
    }

    BlockFace[] faces = { BlockFace.NORTH, BlockFace.NORTH_EAST, BlockFace.EAST, BlockFace.SOUTH_EAST, BlockFace.SOUTH, BlockFace.SOUTH_WEST, BlockFace.WEST, BlockFace.NORTH_WEST };
    short[] blocks = schematic.getBlocks();
    byte[] blockData = schematic.getData();

    short length = schematic.getLength();
    short width = schematic.getWidth();
    short height = schematic.getHeight();

    for (int x = 0; x < width; ++x) {
        for (int y = 0; y < height; ++y) {
            for (int z = 0; z < length; ++z) {
                int index = y * width * length + z * width + x;

                int blockX = x + loc.getBlockX() - length / 2;
                int blockY = y + loc.getBlockY();
                int blockZ = z + loc.getBlockZ() - width / 2;
                Block block = new Location(loc.getWorld(), blockX, blockY, blockZ).getBlock();

                if ((!block.getType().isSolid() && !block.getType().isInteractable() && !MaterialCollections.getAllUnbreakableBlocks().contains(block.getType())) || block.getType() == Material.AIR || block.getType() == Material.CAVE_AIR || org.bukkit.Tag.SAPLINGS.isTagged(block.getType())) {
                    Material material = parseId(blocks[index], blockData[index]);

                    if (material != null) {
                        if (blocks[index] != 0) {
                            block.setType(material);
                        }

                        if (org.bukkit.Tag.LEAVES.isTagged(material)) {
                            if (ThreadLocalRandom.current().nextInt(100) < 25) {
                                BlockStorage.store(block, tree.getItem());
                            }
                        }
                        else if (material == Material.PLAYER_HEAD) {
                            Rotatable s = (Rotatable) block.getBlockData();
                            s.setRotation(faces[ThreadLocalRandom.current().nextInt(faces.length)]);
                            block.setBlockData(s);

                            SkullBlock.setFromHash(block, tree.getTexture());
                            BlockStorage.store(block, tree.getFruit());
                        }
                    }
                }
            }
        }
    }
}
 
Example 20
Source File: ArmorStandDisplayItem.java    From QuickShop-Reremake with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Location getDisplayLocation() {
    BlockFace containerBlockFace = BlockFace.NORTH; // Set default vaule
    if (this.shop.getLocation().getBlock().getBlockData() instanceof Directional) {
        containerBlockFace =
                ((Directional) this.shop.getLocation().getBlock().getBlockData())
                        .getFacing(); // Replace by container face.
    }
    // Fix specific block facing
    Material type = this.shop.getLocation().getBlock().getType();
    if (type.name().contains("ANVIL")
            || type.name().contains("FENCE")
            || type.name().contains("WALL")) {
        switch (containerBlockFace) {
            case SOUTH:
                containerBlockFace = BlockFace.WEST;
                break;
            case NORTH:
                containerBlockFace = BlockFace.EAST;
            case EAST:
                containerBlockFace = BlockFace.NORTH;
            case WEST:
                containerBlockFace = BlockFace.SOUTH;
            default:
                break;
        }
    }

    Location asloc = getCenter(this.shop.getLocation());
    Util.debugLog("containerBlockFace " + containerBlockFace);
    if (this.originalItemStack.getType().isBlock()) {
        asloc.add(0, 0.5, 0);
    }
    switch (containerBlockFace) {
        case SOUTH:
            asloc.add(0, -0.5, 0);
            asloc.setYaw(0);
            Util.debugLog("Block face as SOUTH");
            break;
        case WEST:
            asloc.add(0, -0.5, 0);
            asloc.setYaw(90);
            Util.debugLog("Block face as WEST");
            break;
        case EAST:
            asloc.add(0, -0.5, 0);
            asloc.setYaw(-90);
            Util.debugLog("Block face as EAST");
            break;
        case NORTH:
            asloc.add(0, -0.5, 0);
            asloc.setYaw(180);
            Util.debugLog("Block face as NORTH");
            break;
        default:
            break;
    }
    return asloc;
}