1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-20 11:45:51 +00:00

Use the actual tool item in calls to getDrops()

This commit is contained in:
creator3 2019-12-16 11:47:47 -05:00
parent 8b177df6c8
commit d698840e1f
6 changed files with 8 additions and 23 deletions

View File

@ -27,9 +27,6 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
public class ExplosivePickaxe extends SimpleSlimefunItem<BlockBreakHandler> implements NotPlaceable, DamageableItem { public class ExplosivePickaxe extends SimpleSlimefunItem<BlockBreakHandler> implements NotPlaceable, DamageableItem {
// Determines the drops an ExplosivePickaxe will get
private static final ItemStack EFFECTIVE_PICKAXE = new ItemStack(Material.DIAMOND_PICKAXE);
private String[] blacklist; private String[] blacklist;
private boolean damageOnUse; private boolean damageOnUse;
@ -80,7 +77,7 @@ public class ExplosivePickaxe extends SimpleSlimefunItem<BlockBreakHandler> impl
b.breakNaturally(); b.breakNaturally();
} }
else { else {
for (ItemStack drop: b.getDrops(EFFECTIVE_PICKAXE)) { for (ItemStack drop : b.getDrops(getItem())) {
b.getWorld().dropItemNaturally(b.getLocation(), (b.getType().toString().endsWith("_ORE") && b.getType() != Material.IRON_ORE && b.getType() != Material.GOLD_ORE) ? new CustomItem(drop, fortune): drop); b.getWorld().dropItemNaturally(b.getLocation(), (b.getType().toString().endsWith("_ORE") && b.getType() != Material.IRON_ORE && b.getType() != Material.GOLD_ORE) ? new CustomItem(drop, fortune): drop);
} }
b.setType(Material.AIR); b.setType(Material.AIR);

View File

@ -20,9 +20,6 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
public class ExplosiveShovel extends SimpleSlimefunItem<BlockBreakHandler> implements NotPlaceable, DamageableItem { public class ExplosiveShovel extends SimpleSlimefunItem<BlockBreakHandler> implements NotPlaceable, DamageableItem {
// Determines the drops an ExplosiveShovel will get
private static final ItemStack EFFECTIVE_SHOVEL = new ItemStack(Material.DIAMOND_SHOVEL);
private boolean damageOnUse; private boolean damageOnUse;
public ExplosiveShovel(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, String[] keys, Object[] values) { public ExplosiveShovel(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, String[] keys, Object[] values) {
@ -55,7 +52,7 @@ public class ExplosiveShovel extends SimpleSlimefunItem<BlockBreakHandler> imple
b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType()); b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType());
for (ItemStack drop: b.getDrops(EFFECTIVE_SHOVEL)) { for (ItemStack drop : b.getDrops(getItem())) {
if (drop != null) { if (drop != null) {
b.getWorld().dropItemNaturally(b.getLocation(), drop); b.getWorld().dropItemNaturally(b.getLocation(), drop);
} }

View File

@ -13,9 +13,6 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
public class HerculesPickaxe extends SimpleSlimefunItem<BlockBreakHandler> { public class HerculesPickaxe extends SimpleSlimefunItem<BlockBreakHandler> {
// Determines the drops a HerculesPickaxe will get
private static final ItemStack EFFECTIVE_PICKAXE = new ItemStack(Material.DIAMOND_PICKAXE);
public HerculesPickaxe(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { public HerculesPickaxe(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe); super(category, item, recipeType, recipe);
} }
@ -36,7 +33,7 @@ public class HerculesPickaxe extends SimpleSlimefunItem<BlockBreakHandler> {
drops.add(new CustomItem(SlimefunItems.GOLD_DUST, 2)); drops.add(new CustomItem(SlimefunItems.GOLD_DUST, 2));
} }
else { else {
for (ItemStack drop: e.getBlock().getDrops(EFFECTIVE_PICKAXE)) { for (ItemStack drop : e.getBlock().getDrops(getItem())) {
drops.add(new CustomItem(drop, drop.getAmount() * 2)); drops.add(new CustomItem(drop, drop.getAmount() * 2));
} }
} }

View File

@ -20,9 +20,6 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
public class LumberAxe extends SimpleSlimefunItem<BlockBreakHandler> implements NotPlaceable { public class LumberAxe extends SimpleSlimefunItem<BlockBreakHandler> implements NotPlaceable {
// Determines the drops a LumberAxe will get
private static final ItemStack EFFECTIVE_AXE = new ItemStack(Material.DIAMOND_AXE);
public LumberAxe(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { public LumberAxe(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe); super(category, item, recipeType, recipe);
} }
@ -47,7 +44,7 @@ public class LumberAxe extends SimpleSlimefunItem<BlockBreakHandler> implements
if (SlimefunPlugin.getProtectionManager().hasPermission(e.getPlayer(), b, ProtectableAction.BREAK_BLOCK)) { if (SlimefunPlugin.getProtectionManager().hasPermission(e.getPlayer(), b, ProtectableAction.BREAK_BLOCK)) {
b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType()); b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType());
for (ItemStack drop: b.getDrops(EFFECTIVE_AXE)) { for (ItemStack drop : b.getDrops(getItem())) {
b.getWorld().dropItemNaturally(b.getLocation(), drop); b.getWorld().dropItemNaturally(b.getLocation(), drop);
} }

View File

@ -19,8 +19,6 @@ import me.mrCookieSlime.Slimefun.Objects.handlers.BlockBreakHandler;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
public class PickaxeOfVeinMining extends SimpleSlimefunItem<BlockBreakHandler> { public class PickaxeOfVeinMining extends SimpleSlimefunItem<BlockBreakHandler> {
// Determines the drops a PickaxeOfVeinMining will get
private static final ItemStack EFFECTIVE_PICKAXE = new ItemStack(Material.DIAMOND_PICKAXE);
public PickaxeOfVeinMining(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { public PickaxeOfVeinMining(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe); super(category, item, recipeType, recipe);
@ -42,7 +40,7 @@ public class PickaxeOfVeinMining extends SimpleSlimefunItem<BlockBreakHandler> {
if (SlimefunPlugin.getProtectionManager().hasPermission(e.getPlayer(), b.getLocation(), ProtectableAction.BREAK_BLOCK)) { if (SlimefunPlugin.getProtectionManager().hasPermission(e.getPlayer(), b.getLocation(), ProtectableAction.BREAK_BLOCK)) {
b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType()); b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType());
for (ItemStack drop: b.getDrops(EFFECTIVE_PICKAXE)) { for (ItemStack drop : b.getDrops(getItem())) {
b.getWorld().dropItemNaturally(b.getLocation(), drop.getType().isBlock() ? drop: new CustomItem(drop, fortune)); b.getWorld().dropItemNaturally(b.getLocation(), drop.getType().isBlock() ? drop: new CustomItem(drop, fortune));
} }

View File

@ -18,8 +18,7 @@ import me.mrCookieSlime.Slimefun.api.BlockStorage;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
public class SmeltersPickaxe extends SimpleSlimefunItem<BlockBreakHandler> { public class SmeltersPickaxe extends SimpleSlimefunItem<BlockBreakHandler> {
// Determines the drops a SmeltersPickaxe will get
private static final ItemStack EFFECTIVE_PICKAXE = new ItemStack(Material.DIAMOND_PICKAXE);
public SmeltersPickaxe(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { public SmeltersPickaxe(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe); super(category, item, recipeType, recipe);
} }
@ -36,8 +35,8 @@ public class SmeltersPickaxe extends SimpleSlimefunItem<BlockBreakHandler> {
if (BlockStorage.hasBlockInfo(e.getBlock())) return true; if (BlockStorage.hasBlockInfo(e.getBlock())) return true;
if (e.getBlock().getType() == Material.PLAYER_HEAD) return true; if (e.getBlock().getType() == Material.PLAYER_HEAD) return true;
Collection<ItemStack> blockDrops = e.getBlock().getDrops(EFFECTIVE_PICKAXE); Collection<ItemStack> blockDrops = e.getBlock().getDrops(getItem());
for (ItemStack drop: blockDrops) { for (ItemStack drop : blockDrops) {
if (drop != null) { if (drop != null) {
ItemStack output = drop; ItemStack output = drop;