org.bukkit.Material#PISTON源码实例Demo

下面列出了org.bukkit.Material#PISTON 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Slimefun4   文件: MultiBlock.java
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;
}
 
源代码2 项目: Slimefun4   文件: IndustrialMiner.java
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();
}
 
源代码3 项目: Slimefun4   文件: IndustrialMiner.java
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) };
    }
}
 
源代码4 项目: Slimefun4   文件: PressureChamber.java
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);
}
 
源代码5 项目: Slimefun4   文件: Compressor.java
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
	);
}
 
源代码6 项目: Slimefun4   文件: TestMultiBlocks.java
@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));
}
 
源代码7 项目: Slimefun4   文件: ActiveMiner.java
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();
    }
}
 
 方法所在类
 同类方法