Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import org.bukkit.inventory.ItemStack;

import io.github.bakedlibs.dough.blocks.Vein;
import io.github.bakedlibs.dough.items.CustomItemStack;
import io.github.bakedlibs.dough.protection.Interaction;
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
Expand All @@ -24,6 +23,7 @@
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag;
import me.mrCookieSlime.Slimefun.api.BlockStorage;

/**
* The {@link PickaxeOfVeinMining} is a powerful tool which allows you to mine an entire vein of ores
Expand All @@ -48,22 +48,26 @@ public PickaxeOfVeinMining(ItemGroup itemGroup, SlimefunItemStack item, RecipeTy
return (e, tool, fortune, drops) -> {
if (SlimefunTag.PICKAXE_OF_VEIN_MINING_BLOCKS.isTagged(e.getBlock().getType())) {
List<Block> blocks = Vein.find(e.getBlock(), maxBlocks.getValue(), b -> SlimefunTag.PICKAXE_OF_VEIN_MINING_BLOCKS.isTagged(b.getType()));
breakBlocks(e.getPlayer(), blocks, fortune, tool);
breakBlocks(e.getPlayer(), blocks, tool);
}
};
}

@ParametersAreNonnullByDefault
private void breakBlocks(Player p, List<Block> blocks, int fortune, ItemStack tool) {
private void breakBlocks(Player p, List<Block> blocks, ItemStack tool) {
for (Block b : blocks) {
if (BlockStorage.check(b.getLocation()) != null) {
continue;
}

if (Slimefun.getProtectionManager().hasPermission(p, b.getLocation(), Interaction.BREAK_BLOCK)) {
b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType());

if (tool.containsEnchantment(Enchantment.SILK_TOUCH)) {
b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(b.getType()));
} else {
for (ItemStack drop : b.getDrops(tool)) {
b.getWorld().dropItemNaturally(b.getLocation(), drop.getType().isBlock() ? drop : CustomItemStack.create(drop, fortune));
b.getWorld().dropItemNaturally(b.getLocation(), drop);
}
}

Expand All @@ -72,4 +76,4 @@ private void breakBlocks(Player p, List<Block> blocks, int fortune, ItemStack to
}
}

}
}