diff --git a/CHANGELOG.md b/CHANGELOG.md index 527b51960..fb99aaf7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ * Fixed #2793 * Fixed #2809 * Fixed #2810 +* Fixed #2804 * Fixed a small exception which gets thrown when Slimefun is disabled due to an invalid environment ## Release Candidate 20 (30 Jan 2021) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/GoldPan.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/GoldPan.java index 16848bbd7..c2cada5b9 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/GoldPan.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/GoldPan.java @@ -96,10 +96,6 @@ public class GoldPan extends SimpleSlimefunItem implements Recip for (GoldPanDrop setting : drops) { randomizer.add(setting.getOutput(), setting.getValue()); } - - if (randomizer.sumWeights() < 100) { - randomizer.add(new ItemStack(Material.AIR), 100 - randomizer.sumWeights()); - } } /** @@ -110,7 +106,10 @@ public class GoldPan extends SimpleSlimefunItem implements Recip */ @Nonnull public ItemStack getRandomOutput() { - return randomizer.getRandom(); + ItemStack item = randomizer.getRandom(); + + // Fixes #2804 + return item != null ? item : new ItemStack(Material.AIR); } @Override @@ -126,12 +125,14 @@ public class GoldPan extends SimpleSlimefunItem implements Recip if (block.isPresent()) { Block b = block.get(); + // Check the clicked block type and for protections if (b.getType() == getTargetMaterial() && SlimefunPlugin.getProtectionManager().hasPermission(e.getPlayer(), b.getLocation(), ProtectableAction.BREAK_BLOCK)) { ItemStack output = getRandomOutput(); b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType()); b.setType(Material.AIR); + // Make sure that the randomly selected item is not air if (output.getType() != Material.AIR) { b.getWorld().dropItemNaturally(b.getLocation(), output.clone()); } @@ -148,6 +149,7 @@ public class GoldPan extends SimpleSlimefunItem implements Recip * * @return the {@link EntityInteractHandler} of this {@link SlimefunItem} */ + @Nonnull public EntityInteractHandler onEntityInteract() { return (e, item, offHand) -> { if (!(e.getRightClicked() instanceof ItemFrame)) {