Java Code Examples for org.bukkit.Material#CAVE_AIR

The following examples show how to use org.bukkit.Material#CAVE_AIR . 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: Crucible.java    From Slimefun4 with GNU General Public License v3.0 6 votes vote down vote up
private void placeLiquid(Block block, boolean water) {
    if (block.getType() == Material.AIR || block.getType() == Material.CAVE_AIR || block.getType() == Material.VOID_AIR) {
        block.setType(water ? Material.WATER : Material.LAVA);
    }
    else {
        if (water && block.getBlockData() instanceof Waterlogged) {
            Waterlogged wl = (Waterlogged) block.getBlockData();
            wl.setWaterlogged(true);
            block.setBlockData(wl, false);
            block.getWorld().playSound(block.getLocation(), Sound.ENTITY_PLAYER_SPLASH, 1F, 1F);
            return;
        }

        if (BlockStorage.hasBlockInfo(block)) {
            BlockStorage.clearBlockInfo(block);
        }
    }

    runPostTask(block, water ? Sound.ENTITY_PLAYER_SPLASH : Sound.BLOCK_LAVA_POP, 1);
}
 
Example 2
Source File: ProgrammableAndroid.java    From Slimefun4 with GNU General Public License v3.0 5 votes vote down vote up
protected void move(Block b, BlockFace face, Block block) {
    if (block.getY() > 0 && block.getY() < block.getWorld().getMaxHeight() && (block.getType() == Material.AIR || block.getType() == Material.CAVE_AIR)) {
        block.setType(Material.PLAYER_HEAD);
        Rotatable blockData = (Rotatable) block.getBlockData();
        blockData.setRotation(face.getOppositeFace());
        block.setBlockData(blockData);

        SkullBlock.setFromBase64(block, texture);

        b.setType(Material.AIR);
        BlockStorage.moveBlockInfo(b.getLocation(), block.getLocation());
    }
}
 
Example 3
Source File: BlockListener.java    From MineTinker with GNU General Public License v3.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onHoeUse(PlayerInteractEvent event) {
	Player player = event.getPlayer();

	if (Lists.WORLDS.contains(player.getWorld().getName())) {
		return;
	}

	if (!(player.getGameMode() == GameMode.SURVIVAL || player.getGameMode() == GameMode.ADVENTURE)) {
		return;
	}

	ItemStack tool = player.getInventory().getItemInMainHand();

	if (!ToolType.HOE.contains(tool.getType())) {
		return;
	}

	if (!modManager.isToolViable(tool)) {
		return;
	}

	Block block = event.getClickedBlock();

	boolean apply = false;

	if (event.getAction() == Action.RIGHT_CLICK_BLOCK && block != null) {
		if (block.getType() == Material.GRASS_BLOCK || block.getType() == Material.DIRT)
			apply = true;

		Block b = player.getWorld().getBlockAt(block.getLocation().add(0, 1, 0));
		if (b.getType() != Material.AIR && b.getType() != Material.CAVE_AIR) //Case Block is on top of clicked Block -> No Soil Tilt -> no Exp
			apply = false;
	}

	if (!apply) {
		return;
	}

	if (!modManager.durabilityCheck(event, player, tool)) {
		return;
	}

	modManager.addExp(player, tool, MineTinker.getPlugin().getConfig().getInt("ExpPerBlockBreak"));

	MTPlayerInteractEvent interactEvent = new MTPlayerInteractEvent(tool, event);
	Bukkit.getPluginManager().callEvent(interactEvent);
}
 
Example 4
Source File: BlockListener.java    From MineTinker with GNU General Public License v3.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onShovelUse(PlayerInteractEvent event) {
	Player player = event.getPlayer();

	if (Lists.WORLDS.contains(player.getWorld().getName())) {
		return;
	}

	if (!(player.getGameMode() == GameMode.SURVIVAL || player.getGameMode() == GameMode.ADVENTURE)) {
		return;
	}

	ItemStack tool = player.getInventory().getItemInMainHand();

	if (!ToolType.SHOVEL.contains(tool.getType())) {
		return;
	}

	if (!modManager.isToolViable(tool)) {
		return;
	}

	boolean apply = false;

	if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock() != null) {
		if (event.getClickedBlock().getType() == Material.GRASS_BLOCK)
			apply = true;

		Block b = player.getWorld().getBlockAt(event.getClickedBlock().getLocation().add(0, 1, 0));
		if (b.getType() != Material.AIR && b.getType() != Material.CAVE_AIR)
			//Case Block is on top of clicked Block -> No Path created -> no Exp
			apply = false;
	}

	if (!apply) {
		return;
	}

	if (!modManager.durabilityCheck(event, player, tool)) {
		return;
	}

	modManager.addExp(player, tool, MineTinker.getPlugin().getConfig().getInt("ExpPerBlockBreak"));

	MTPlayerInteractEvent interactEvent = new MTPlayerInteractEvent(tool, event);
	Bukkit.getPluginManager().callEvent(interactEvent);
}
 
Example 5
Source File: NewBlockCompat.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean isEmpty(Material type) {
	return type == Material.AIR || type == Material.CAVE_AIR || type == Material.VOID_AIR;
}
 
Example 6
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());
                        }
                    }
                }
            }
        }
    }
}