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

The following examples show how to use org.bukkit.block.BlockFace#SELF . 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: GrindStone.java    From Slimefun4 with GNU General Public License v3.0 6 votes vote down vote up
public GrindStone(Category category, SlimefunItemStack item) {
       super(category, item, 
			new ItemStack[] {null, null, null, null, new ItemStack(Material.OAK_FENCE), null, null, new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), null},
			new ItemStack[] {
					new ItemStack(Material.BLAZE_ROD), new ItemStack(Material.BLAZE_POWDER, 4), 
					new ItemStack(Material.BONE), new ItemStack(Material.BONE_MEAL, 4), 
					new ItemStack(Material.GRAVEL), new ItemStack(Material.FLINT), 
					new ItemStack(Material.ENDER_EYE), new CustomItem(SlimefunItems.ENDER_LUMP_1, 2), 
					new ItemStack(Material.COBBLESTONE), new ItemStack(Material.GRAVEL), 
					new ItemStack(Material.ANDESITE), new ItemStack(Material.GRAVEL),
					new ItemStack(Material.DIORITE), new ItemStack(Material.GRAVEL),
					new ItemStack(Material.GRANITE), new ItemStack(Material.GRAVEL),
					new ItemStack(Material.DIRT), SlimefunItems.STONE_CHUNK, 
					new ItemStack(Material.SANDSTONE), new ItemStack(Material.SAND, 4), 
					new ItemStack(Material.RED_SANDSTONE), new ItemStack(Material.RED_SAND, 4),
					new ItemStack(Material.PRISMARINE_BRICKS), new ItemStack(Material.PRISMARINE, 2),
					new ItemStack(Material.PRISMARINE), new ItemStack(Material.PRISMARINE_SHARD, 4)
			},
			BlockFace.SELF
	);
}
 
Example 2
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 3
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 4
Source File: CraftBlock.java    From Thermos with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Notch uses a 0-5 to mean DOWN, UP, NORTH, SOUTH, WEST, EAST
 * in that order all over. This method is convenience to convert for us.
 *
 * @return BlockFace the BlockFace represented by this number
 */
public static BlockFace notchToBlockFace(int notch) {
    switch (notch) {
    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: ArmorForge.java    From Slimefun4 with GNU General Public License v3.0 5 votes vote down vote up
public ArmorForge(Category category, SlimefunItemStack item) {
    super(category, item, new ItemStack[] { 
          null, null, null, 
          null, new ItemStack(Material.ANVIL), null, 
          null, new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), null 
    }, new ItemStack[0], BlockFace.SELF);
}
 
Example 6
Source File: Compressor.java    From Slimefun4 with GNU General Public License v3.0 5 votes vote down vote up
public Compressor(Category category, SlimefunItemStack item) {
       super(category, item, 
			new ItemStack[] {null, null, null, null, new ItemStack(Material.NETHER_BRICK_FENCE), null, new ItemStack(Material.PISTON), new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), new ItemStack(Material.PISTON)},
			new ItemStack[] {
				new CustomItem(SlimefunItems.STONE_CHUNK, 4), new ItemStack(Material.COBBLESTONE),
				new ItemStack(Material.FLINT, 8), new ItemStack(Material.COBBLESTONE)
			},
			BlockFace.SELF
	);
}
 
Example 7
Source File: TestMultiBlocks.java    From Slimefun4 with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testNotEqual() {
    SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MULTIBLOCK_TEST", new CustomItem(Material.BRICK, "&5Multiblock Test"));

    MultiBlock multiblock = new MultiBlock(item, new Material[] { Material.BIRCH_WOOD, Material.BIRCH_WOOD, Material.BIRCH_WOOD, null, Material.CRAFTING_TABLE, null, Material.BIRCH_WOOD, Material.DISPENSER, Material.BIRCH_WOOD }, BlockFace.DOWN);
    MultiBlock multiblock2 = new MultiBlock(item, new Material[] { Material.BIRCH_WOOD, Material.BIRCH_WOOD, Material.BIRCH_WOOD, null, Material.EMERALD_BLOCK, null, Material.BIRCH_WOOD, Material.DISPENSER, Material.BIRCH_WOOD }, BlockFace.DOWN);
    MultiBlock multiblock3 = new MultiBlock(item, new Material[] { Material.DROPPER, Material.BIRCH_WOOD, Material.BIRCH_WOOD, null, Material.DIAMOND_BLOCK, null, Material.BIRCH_WOOD, Material.DISPENSER, Material.TNT }, BlockFace.DOWN);
    MultiBlock multiblock4 = new MultiBlock(item, new Material[] { Material.BIRCH_WOOD, Material.BIRCH_WOOD, Material.BIRCH_WOOD, null, Material.CRAFTING_TABLE, null, Material.BIRCH_WOOD, Material.DISPENSER, Material.BIRCH_WOOD }, BlockFace.SELF);

    Assertions.assertFalse(multiblock.equals(null));
    Assertions.assertFalse(multiblock.equals(multiblock2));
    Assertions.assertFalse(multiblock.equals(multiblock3));
    Assertions.assertFalse(multiblock.equals(multiblock4));
}
 
Example 8
Source File: CraftBlock.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
public int getBlockPower(BlockFace face) {
    int power = 0;
    BlockRedstoneWire wire = Blocks.redstone_wire;
    net.minecraft.world.World world = chunk.getHandle().worldObj;
    if ((face == BlockFace.DOWN || face == BlockFace.SELF) && world.getIndirectPowerOutput(x, y - 1, z, 0)) power = wire.func_150178_a(world, x, y - 1, z, power);
    if ((face == BlockFace.UP || face == BlockFace.SELF) && world.getIndirectPowerOutput(x, y + 1, z, 1)) power = wire.func_150178_a(world, x, y + 1, z, power);
    if ((face == BlockFace.EAST || face == BlockFace.SELF) && world.getIndirectPowerOutput(x + 1, y, z, 2)) power = wire.func_150178_a(world, x + 1, y, z, power);
    if ((face == BlockFace.WEST || face == BlockFace.SELF) && world.getIndirectPowerOutput(x - 1, y, z, 3)) power = wire.func_150178_a(world, x - 1, y, z, power);
    if ((face == BlockFace.NORTH || face == BlockFace.SELF) && world.getIndirectPowerOutput(x, y, z - 1, 4)) power = wire.func_150178_a(world, x, y, z - 1, power);
    if ((face == BlockFace.SOUTH || face == BlockFace.SELF) && world.getIndirectPowerOutput(x, y, z + 1, 5)) power = wire.func_150178_a(world, x, y, z - 1, power);
    return power > 0 ? power : (face == BlockFace.SELF ? isBlockIndirectlyPowered() : isBlockFaceIndirectlyPowered(face)) ? 15 : 0;
}
 
Example 9
Source File: Direction.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @param b
 * @return The facing of the block or {@link BlockFace#SELF} if the block doesn't have a facing.
 */
@SuppressWarnings({"deprecation", "null"})
public static BlockFace getFacing(final Block b) {
	final Material m = b.getType();
	if (!Directional.class.isAssignableFrom(m.getData()))
		return BlockFace.SELF;
	return ((Directional) m.getNewData(b.getData())).getFacing();
}
 
Example 10
Source File: DirectionUtil.java    From VoxelGamesLibv2 with MIT License 5 votes vote down vote up
/**
 * Gets the next BlockFace clock wise
 *
 * @param direction the starting direction
 * @param steps     the amount of steps to go
 * @return the direction
 */
@Nonnull
public static BlockFace getNext(@Nonnull BlockFace direction, int steps) {
    for (int i = 0; i < RADIAL.length; i++) {
        if (RADIAL[i] == direction) {
            return RADIAL[Math.floorMod(i + steps, RADIAL.length)];
        }
    }
    return BlockFace.SELF;
}
 
Example 11
Source File: CraftHanging.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
public BlockFace getFacing() {
    EnumFacing direction = this.getHandle().facingDirection;
    if (direction == null) return BlockFace.SELF;
    switch (direction) {
        case SOUTH:
        default:
            return BlockFace.SOUTH;
        case WEST:
            return BlockFace.WEST;
        case NORTH:
            return BlockFace.NORTH;
        case EAST:
            return BlockFace.EAST;
    }
}
 
Example 12
Source File: TestMultiblockListener.java    From Slimefun4 with GNU General Public License v3.0 5 votes vote down vote up
@BeforeAll
public static void load() {
    server = MockBukkit.mock();
    TestUtilities.registerDefaultTags(server);
    plugin = MockBukkit.load(SlimefunPlugin.class);
    listener = new MultiBlockListener(plugin);
    SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MULTIBLOCK_LISTENER_TEST", new CustomItem(Material.DIAMOND, "&9Some multiblock item"));
    multiblock = new MultiBlock(item, new Material[] { null, Material.EMERALD_BLOCK, null, null, Material.DIAMOND_BLOCK, null, null, Material.LAPIS_BLOCK, null }, BlockFace.SELF);
    SlimefunPlugin.getRegistry().getMultiBlocks().add(multiblock);
}
 
Example 13
Source File: Tree.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Get direction of the log
 *
 * @return one of:
 * <ul>
 * <li>BlockFace.TOP for upright (default)
 * <li>BlockFace.NORTH (east-west)
 * <li>BlockFace.WEST (north-south)
 * <li>BlockFace.SELF (directionless)
 * </ul>
 */
@SuppressWarnings("deprecation")
public BlockFace getDirection() {
    switch ((getData() >> 2) & 0x3) {
        case 0: // Up-down
        default:
            return BlockFace.UP;
        case 1: // North-south
            return BlockFace.WEST;
        case 2: // East-west
            return BlockFace.NORTH;
        case 3: // Directionless (bark on all sides)
            return BlockFace.SELF;
    }
}
 
Example 14
Source File: TableSaw.java    From Slimefun4 with GNU General Public License v3.0 5 votes vote down vote up
public TableSaw(Category category, SlimefunItemStack item) {
    super(category, item, new ItemStack[] { null, null, null, new ItemStack(Material.SMOOTH_STONE_SLAB), new ItemStack(Material.STONECUTTER), new ItemStack(Material.SMOOTH_STONE_SLAB), null, new ItemStack(Material.IRON_BLOCK), null }, new ItemStack[0], BlockFace.SELF);

    for (Material log : Tag.LOGS.getValues()) {
        Optional<Material> planks = MaterialConverter.getPlanksFromLog(log);

        if (planks.isPresent()) {
            displayedRecipes.add(new ItemStack(log));
            displayedRecipes.add(new ItemStack(planks.get(), 8));
        }
    }
}
 
Example 15
Source File: XBlock.java    From IridiumSkyblock with GNU General Public License v2.0 5 votes vote down vote up
public static BlockFace getDirection(Block block) {
    if (XMaterial.ISFLAT) {
        if (!(block.getBlockData() instanceof Directional)) return BlockFace.SELF;
        Directional direction = (Directional) block.getBlockData();
        return direction.getFacing();
    }

    BlockState state = block.getState();
    MaterialData data = state.getData();
    if (data instanceof org.bukkit.material.Directional) {
        return ((org.bukkit.material.Directional) data).getFacing();
    }
    return null;
}
 
Example 16
Source File: VisualEffect.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Object getData(final @Nullable Object raw, final Location l) {
	if (raw == null)
		return BlockFace.SELF;
	return Direction.getFacing(((Direction) raw).getDirection(l), false); // TODO allow this to not be a literal
}
 
Example 17
Source File: AutomatedPanningMachine.java    From Slimefun4 with GNU General Public License v3.0 4 votes vote down vote up
public AutomatedPanningMachine(Category category, SlimefunItemStack item) {
    super(category, item, new ItemStack[] { null, null, null, null, new ItemStack(Material.OAK_TRAPDOOR), null, null, new ItemStack(Material.CAULDRON), null }, new ItemStack[0], BlockFace.SELF);
}
 
Example 18
Source File: BlockFromToEvent.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public BlockFromToEvent(final Block block, final Block toBlock) {
    super(block);
    this.to = toBlock;
    this.face = BlockFace.SELF;
    this.cancel = false;
}
 
Example 19
Source File: EnhancedCraftingTable.java    From Slimefun4 with GNU General Public License v3.0 4 votes vote down vote up
public EnhancedCraftingTable(Category category, SlimefunItemStack item) {
    super(category, item, new ItemStack[] { null, null, null, null, new ItemStack(Material.CRAFTING_TABLE), null, null, new ItemStack(Material.DISPENSER), null }, new ItemStack[0], BlockFace.SELF);
}
 
Example 20
Source File: OreCrusher.java    From Slimefun4 with GNU General Public License v3.0 4 votes vote down vote up
public OreCrusher(Category category, SlimefunItemStack item) {
    super(category, item, new ItemStack[] { null, null, null, null, new ItemStack(Material.NETHER_BRICK_FENCE), null, new ItemStack(Material.IRON_BARS), new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), new ItemStack(Material.IRON_BARS) }, new ItemStack[] { new ItemStack(Material.COBBLESTONE, 8), new ItemStack(Material.SAND, 1), SlimefunItems.GOLD_4K, SlimefunItems.GOLD_DUST, new ItemStack(Material.GRAVEL), new ItemStack(Material.SAND), new ItemStack(Material.MAGMA_BLOCK, 4), SlimefunItems.SULFATE }, BlockFace.SELF);

    addItemSetting(doubleOres);
}