Java Code Examples for org.bukkit.Material#GOLD_ORE

The following examples show how to use org.bukkit.Material#GOLD_ORE . 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: DoubleGoldListener.java    From UhcCore with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler
public void onBlockBreak(BlockBreakEvent e) {

    if (isActivated(Scenario.CUTCLEAN) || isActivated(Scenario.TRIPLEORES) || isActivated(Scenario.VEINMINER)){
        return;
    }

    Block block = e.getBlock();
    Location loc = e.getBlock().getLocation().add(0.5, 0, 0.5);

    if (block.getType() == Material.GOLD_ORE){
        block.setType(Material.AIR);
        loc.getWorld().dropItem(loc,new ItemStack(Material.GOLD_INGOT, 2));
        UhcItems.spawnExtraXp(loc,6);
    }
}
 
Example 2
Source File: CaveOresOnlyPopulator.java    From UhcCore with GNU General Public License v3.0 6 votes vote down vote up
private void scanChunk(Chunk chunk){
    for (int x = 0; x < 16; x++){
        for (int y = 5; y < 30; y++){
            for (int z = 0; z < 16; z++){

                Block block = chunk.getBlock(x, y, z);
                Material type = block.getType();
                if (
                        type == Material.DIAMOND_ORE ||
                        type == Material.GOLD_ORE ||
                        type == Material.LAPIS_ORE
                ){
                    Vein vein = new Vein();
                    vein.process(block);
                    if (!vein.isConnectedToAir()){
                        vein.setToStone();
                    }
                }

            }
        }
    }
}
 
Example 3
Source File: GoldLessListener.java    From UhcCore with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler (priority = EventPriority.LOW)
public void onBlockBreak(BlockBreakEvent e){
    if (e.getBlock().getType() == Material.GOLD_ORE){
        e.getBlock().setType(Material.AIR);
    }

}
 
Example 4
Source File: ExplosiveTool.java    From Slimefun4 with GNU General Public License v3.0 5 votes vote down vote up
protected void breakBlock(Player p, ItemStack item, Block b, int fortune, List<ItemStack> drops) {
    if (b.getType() != Material.AIR && !b.isLiquid() && !MaterialCollections.getAllUnbreakableBlocks().contains(b.getType()) && SlimefunPlugin.getProtectionManager().hasPermission(p, b.getLocation(), ProtectableAction.BREAK_BLOCK)) {
        SlimefunPlugin.getProtectionManager().logAction(p, b, ProtectableAction.BREAK_BLOCK);

        b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType());
        SlimefunItem sfItem = BlockStorage.check(b);

        if (sfItem != null && !sfItem.useVanillaBlockBreaking()) {
            SlimefunBlockHandler handler = SlimefunPlugin.getRegistry().getBlockHandlers().get(sfItem.getID());

            if (handler != null && !handler.onBreak(p, b, sfItem, UnregisterReason.PLAYER_BREAK)) {
                drops.add(BlockStorage.retrieve(b));
            }
        }
        else if (b.getType() == Material.PLAYER_HEAD || b.getType().name().endsWith("_SHULKER_BOX")) {
            b.breakNaturally();
        }
        else {
            boolean applyFortune = b.getType().name().endsWith("_ORE") && b.getType() != Material.IRON_ORE && b.getType() != Material.GOLD_ORE;

            for (ItemStack drop : b.getDrops(getItem())) {
                // For some reason this check is necessary with Paper
                if (drop != null && drop.getType() != Material.AIR) {
                    b.getWorld().dropItemNaturally(b.getLocation(), applyFortune ? new CustomItem(drop, fortune) : drop);
                }
            }

            b.setType(Material.AIR);
        }

        damageItem(p, item);
    }
}
 
Example 5
Source File: HerculesPickaxe.java    From Slimefun4 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public BlockBreakHandler getItemHandler() {
    return new BlockBreakHandler() {

        @Override
        public boolean isPrivate() {
            return false;
        }

        @Override
        public boolean onBlockBreak(BlockBreakEvent e, ItemStack item, int fortune, List<ItemStack> drops) {
            if (e.getBlock().getType().toString().endsWith("_ORE") && isItem(item)) {
                if (!Slimefun.hasUnlocked(e.getPlayer(), HerculesPickaxe.this, true)) {
                    return true;
                }

                if (e.getBlock().getType() == Material.IRON_ORE) {
                    drops.add(new CustomItem(SlimefunItems.IRON_DUST, 2));
                }
                else if (e.getBlock().getType() == Material.GOLD_ORE) {
                    drops.add(new CustomItem(SlimefunItems.GOLD_DUST, 2));
                }
                else {
                    for (ItemStack drop : e.getBlock().getDrops(getItem())) {
                        drops.add(new CustomItem(drop, drop.getAmount() * 2));
                    }
                }

                return true;
            }
            else return false;
        }
    };
}