private final ItemStack getDrops(Block b) { for(ItemStack im : b.getDrops()) { return im; } return null; }
private final ItemStack getDrops(Block b) { ItemStack item = null; for(ItemStack im : b.getDrops()) { item = im; } return item; }
@Override public Collection<ItemStack> getDrops() { return base.getDrops(); }
public Collection<ItemStack> getDrops(ItemStack item) { return base.getDrops(item); }
@Override public Collection<MCItemStack> getDrops() { Collection<MCItemStack> collection = new ArrayList<>(); for(ItemStack is : b.getDrops()) { collection.add(new BukkitMCItemStack(is)); } return collection; }
@Override public Collection<MCItemStack> getDrops(MCItemStack tool) { Collection<MCItemStack> collection = new ArrayList<>(); for(ItemStack is : b.getDrops(((BukkitMCItemStack) tool).asItemStack())) { collection.add(new BukkitMCItemStack(is)); } return collection; }
/** * Gets a {@code Collection<ItemStack>} of item drops from a single block. * * @param block The single block * @param type The Material type to change the block into * @param data The block data to change the block into * @param breakitem Unused * @return The item drops fromt the specified block */ public static Collection<ItemStack> getDrops(final Block block, final Material type, final byte data, final ItemStack breakitem) { final BlockState tempstate = block.getState(); block.setType(type); block.setData(data); final Collection<ItemStack> item = block.getDrops(); tempstate.update(true); return item; }
@Override public boolean onBlockBreak(BlockBreakEvent e, ItemStack item, int fortune, List<ItemStack> drops) { if (SlimefunManager.isItemSimiliar(item, SlimefunItems.AUTO_SMELT_PICKAXE, true)) { if (e.getBlock().getType().equals(Material.PLAYER_HEAD)) return true; int j = -1; List<ItemStack> dropsList = (List<ItemStack>) e.getBlock().getDrops(); for (int i = 0; i < dropsList.size(); i++) { if (dropsList.get(i) != null) { j++; drops.add(e.getBlock().getType().toString().endsWith("_ORE") ? new CustomItem(dropsList.get(i), fortune): dropsList.get(i)); if (RecipeCalculator.getSmeltedOutput(drops.get(i).getType()) != null) { e.getBlock().getWorld().playEffect(e.getBlock().getLocation(), Effect.MOBSPAWNER_FLAMES, 1); drops.set(j, new CustomItem(RecipeCalculator.getSmeltedOutput(drops.get(i).getType()), drops.get(i).getAmount())); } } } return true; } else return false; } });
@Override public boolean onBlockBreak(BlockBreakEvent e, ItemStack item, int fortune, List<ItemStack> drops) { if (SlimefunManager.isItemSimiliar(e.getPlayer().getInventory().getItemInMainHand(), SlimefunItems.HERCULES_PICKAXE, true) && e.getBlock().getType().toString().endsWith("_ORE")) { 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()) { drops.add(new CustomItem(drop, 2)); } } return true; } else return false; } });
/** * * @param e BlockBreakEvent * @since 4.2.0 */ @EventHandler public void onBlockBreak(BlockBreakEvent e) { List<ItemStack> drops = new ArrayList<ItemStack>(); ItemStack item = e.getPlayer().getInventory().getItemInMainHand(); int fortune = 1; if (item != null) { if (item.getEnchantments().containsKey(Enchantment.LOOT_BONUS_BLOCKS) && !item.getEnchantments().containsKey(Enchantment.SILK_TOUCH)) { fortune = SlimefunStartup.randomize(item.getEnchantmentLevel(Enchantment.LOOT_BONUS_BLOCKS) + 2) - 1; if (fortune <= 0) fortune = 1; fortune = (e.getBlock().getType() == Material.LAPIS_ORE ? 4 + SlimefunStartup.randomize(5) : 1) * (fortune + 1); } if (!item.getEnchantments().containsKey(Enchantment.SILK_TOUCH) && e.getBlock().getType().toString().endsWith("_ORE")) { if (Talisman.checkFor(e, SlimefunItem.getByID("MINER_TALISMAN"))) { if (drops.isEmpty()) drops = (List<ItemStack>) e.getBlock().getDrops(); for (ItemStack drop : new ArrayList<ItemStack>(drops)) { if (!drop.getType().isBlock()) drops.add(new CustomItem(drop, fortune * 2)); } } } } } }
/** * Checks for double drops * * @param blockState Block being broken */ protected static void checkForDoubleDrop(BlockState blockState) { if (mcMMO.getModManager().isCustomLog(blockState) && mcMMO.getModManager().getBlock(blockState).isDoubleDropEnabled()) { Misc.dropItems(Misc.getBlockCenter(blockState), blockState.getBlock().getDrops()); } else { if (Config.getInstance().getWoodcuttingDoubleDropsEnabled(blockState.getBlockData())) { Misc.dropItems(Misc.getBlockCenter(blockState), blockState.getBlock().getDrops()); } } }
private void mine(Block b, Block block) { Collection<ItemStack> drops = block.getDrops(); if (!blockblacklist.contains(block.getType()) && !drops.isEmpty() && CSCoreLib.getLib().getProtectionManager().canBuild(UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner")), block)) { SlimefunItem item = BlockStorage.check(block); if (item != null) { if (fits(b, item.getItem())) { if (SlimefunItem.blockhandler.containsKey(item.getID())) { if (SlimefunItem.blockhandler.get(item.getID()).onBreak(null, block, item, UnregisterReason.ANDROID_DIG)) { pushItems(b, BlockStorage.retrieve(block)); if (SlimefunItem.blockhandler.containsKey(item.getID())) SlimefunItem.blockhandler.get(item.getID()).onBreak(null, block, item, UnregisterReason.ANDROID_DIG); block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType()); block.setType(Material.AIR); } } } } else { ItemStack[] items = drops.toArray(new ItemStack[drops.size()]); if (fits(b, items)) { pushItems(b, items); block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType()); block.setType(Material.AIR); } } } }
for (BlockState blockState : debris) { if (Misc.getRandom().nextFloat() < debrisYield) { Misc.dropItems(Misc.getBlockCenter(blockState), blockState.getBlock().getDrops());
Misc.dropItems(Misc.getBlockCenter(blockState), block.getDrops()); xp = customBlock.getXpGain(); Misc.dropItems(Misc.getBlockCenter(blockState), block.getDrops()); Misc.dropItems(Misc.getBlockCenter(blockState), block.getDrops()); Misc.dropItems(Misc.getBlockCenter(blockState), block.getDrops()); Misc.dropItems(Misc.getBlockCenter(blockState), block.getDrops());
@Override public boolean onBlockBreak(BlockBreakEvent e, ItemStack item, int fortune, List<ItemStack> drops) { if (SlimefunManager.isItemSimiliar(e.getPlayer().getInventory().getItemInMainHand(), SlimefunItems.PICKAXE_OF_VEIN_MINING, true)) { if (e.getBlock().getType().toString().endsWith("_ORE")) { List<Location> blocks = new ArrayList<Location>(); Vein.calculate(e.getBlock().getLocation(), e.getBlock().getLocation(), blocks, 16); for (Location block: blocks) { Block b = block.getBlock(); b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType()); for (ItemStack drop: b.getDrops()) { b.getWorld().dropItemNaturally(b.getLocation(), drop.getType().isBlock() ? drop: new CustomItem(drop, fortune)); } b.setType(Material.AIR); } } return true; } else return false; } });
@Override public boolean onBlockBreak(BlockBreakEvent e, ItemStack item, int fortune, List<ItemStack> drops) { if (SlimefunManager.isItemSimiliar(e.getPlayer().getInventory().getItemInMainHand(), SlimefunItems.LUMBER_AXE, true)) { if (MaterialHelper.isLog( e.getBlock().getType())) { List<Location> logs = new ArrayList<Location>(); TreeCalculator.getTree(e.getBlock().getLocation(), e.getBlock().getLocation(), logs); if (logs.contains(e.getBlock())) logs.remove(e.getBlock()); for (Location b: logs) { if (CSCoreLib.getLib().getProtectionManager().canBuild(e.getPlayer().getUniqueId(), b.getBlock())) { b.getWorld().playEffect(b, Effect.STEP_SOUND, b.getBlock().getType()); for (ItemStack drop: b.getBlock().getDrops()) { b.getWorld().dropItemNaturally(b, drop); } b.getBlock().setType(Material.AIR); } } } return true; } else return false; } });
drops.addAll(block.getDrops()); } else if (falling) { Location blockLocation = block.getLocation();
for (ItemStack drop: b.getDrops()) { b.getWorld().dropItemNaturally(b.getLocation(), (b.getType().toString().endsWith("_ORE") && !b.getType().equals(Material.IRON_ORE) && !b.getType().equals(Material.GOLD_ORE)) ? new CustomItem(drop, fortune): drop);
drops.addAll(block.getDrops()); } else if (falling) { Location blockLocation = block.getLocation();