Java Code Examples for org.bukkit.Material#PISTON

The following examples show how to use org.bukkit.Material#PISTON . 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: MultiBlock.java    From Slimefun4 with GNU General Public License v3.0 6 votes vote down vote up
private boolean compareBlocks(Material a, Material b) {
    if (b != null) {

        for (Tag<Material> tag : SUPPORTED_TAGS) {
            if (tag.isTagged(b)) {
                return tag.isTagged(a);
            }
        }

        // This ensures that the Industrial Miner is still recognized while operating
        if (a == Material.PISTON) {
            return a == b || b == Material.MOVING_PISTON;
        }

        // This ensures that the Industrial Miner is still recognized while operating
        if (b == Material.PISTON) {
            return a == b || a == Material.MOVING_PISTON;
        }

        if (b != a) {
            return false;
        }
    }

    return true;
}
 
Example 2
Source File: IndustrialMiner.java    From Slimefun4 with GNU General Public License v3.0 5 votes vote down vote up
public IndustrialMiner(Category category, SlimefunItemStack item, Material baseMaterial, boolean silkTouch, int range) {
    super(category, item, new ItemStack[] { null, null, null, new CustomItem(Material.PISTON, "Piston (facing up)"), new ItemStack(Material.CHEST), new CustomItem(Material.PISTON, "Piston (facing up)"), new ItemStack(baseMaterial), new ItemStack(SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14) ? Material.BLAST_FURNACE : Material.FURNACE), new ItemStack(baseMaterial) }, new ItemStack[0], BlockFace.UP);

    this.range = range;
    this.silkTouch = silkTouch;

    registerDefaultFuelTypes();
}
 
Example 3
Source File: IndustrialMiner.java    From Slimefun4 with GNU General Public License v3.0 5 votes vote down vote up
private Block[] findPistons(Block chest) {
    Block northern = chest.getRelative(BlockFace.NORTH);

    if (northern.getType() == Material.PISTON) {
        return new Block[] { northern, chest.getRelative(BlockFace.SOUTH) };
    }
    else {
        return new Block[] { chest.getRelative(BlockFace.WEST), chest.getRelative(BlockFace.EAST) };
    }
}
 
Example 4
Source File: PressureChamber.java    From Slimefun4 with GNU General Public License v3.0 5 votes vote down vote up
public PressureChamber(Category category, SlimefunItemStack item) {
    super(category, item, new ItemStack[] { 
            SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14) ? new ItemStack(Material.SMOOTH_STONE_SLAB) : new ItemStack(Material.STONE_SLAB), new CustomItem(Material.DISPENSER, "Dispenser (Facing down)"), SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14) ? new ItemStack(Material.SMOOTH_STONE_SLAB) : new ItemStack(Material.STONE_SLAB), 
            new ItemStack(Material.PISTON), new ItemStack(Material.GLASS), new ItemStack(Material.PISTON), 
            new ItemStack(Material.PISTON), new ItemStack(Material.CAULDRON), new ItemStack(Material.PISTON) 
    }, new ItemStack[0], BlockFace.UP);
}
 
Example 5
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 6
Source File: TestMultiBlocks.java    From Slimefun4 with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testEqualWithMovingPistons() {
    SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "PISTON_MULTIBLOCK_TEST", new CustomItem(Material.BRICK, "&5Multiblock Test"));

    // Some Pistons are moving but that should not interefere with the Multiblock
    MultiBlock multiblock = new MultiBlock(item, new Material[] { Material.PISTON, Material.MOVING_PISTON, Material.PISTON, null, Material.CRAFTING_TABLE, null, Material.PISTON, Material.STONE, Material.PISTON }, BlockFace.DOWN);
    MultiBlock multiblock2 = new MultiBlock(item, new Material[] { Material.MOVING_PISTON, Material.PISTON, Material.MOVING_PISTON, null, Material.CRAFTING_TABLE, null, Material.PISTON, Material.STONE, Material.PISTON }, BlockFace.DOWN);
    MultiBlock multiblock3 = new MultiBlock(item, new Material[] { Material.PISTON, Material.PISTON, Material.STICKY_PISTON, null, Material.CRAFTING_TABLE, null, Material.PISTON, Material.STONE, Material.PISTON }, BlockFace.DOWN);

    Assertions.assertTrue(multiblock.equals(multiblock2));
    Assertions.assertFalse(multiblock.equals(multiblock3));
}
 
Example 7
Source File: ActiveMiner.java    From Slimefun4 with GNU General Public License v3.0 4 votes vote down vote up
private void setPistonState(Block block, boolean extended) {
    if (!running) {
        return;
    }

    try {
        // Smoke Particles around the Chest for dramatic effect
        Location particleLoc = chest.getLocation().clone().add(0, -1, 0);
        block.getWorld().spawnParticle(Particle.SMOKE_NORMAL, particleLoc, 20, 0.7, 0.7, 0.7, 0);

        if (block.getType() == Material.MOVING_PISTON) {
            // Yeah it isn't really cool when this happens
            block.getRelative(BlockFace.UP).setType(Material.AIR);
        }
        else if (block.getType() == Material.PISTON) {
            Block above = block.getRelative(BlockFace.UP);

            // Check if the above block is valid
            if (above.isEmpty() || above.getType() == Material.PISTON_HEAD) {
                Piston piston = (Piston) block.getBlockData();

                // Check if the piston is actually facing upwards
                if (piston.getFacing() == BlockFace.UP) {
                    setExtended(block, piston, extended);
                }
                else {
                    // The pistons must be facing upwards
                    stop("machines.INDUSTRIAL_MINER.piston-facing");
                }
            }
            else {
                // The pistons must be facing upwards
                stop("machines.INDUSTRIAL_MINER.piston-space");
            }
        }
        else {
            // The piston has been destroyed
            stop("machines.INDUSTRIAL_MINER.destroyed");
        }
    }
    catch (Exception e) {
        Slimefun.getLogger().log(Level.SEVERE, e, () -> "An Error occurred while moving a Piston for an Industrial Miner at " + new BlockPosition(block));
        stop();
    }
}