1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-19 19:25:48 +00:00
This commit is contained in:
TheBusyBiscuit 2021-02-07 18:26:08 +01:00
parent d3f4ca4779
commit b224123918
2 changed files with 8 additions and 5 deletions

View File

@ -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)

View File

@ -96,10 +96,6 @@ public class GoldPan extends SimpleSlimefunItem<ItemUseHandler> 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<ItemUseHandler> 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<ItemUseHandler> 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<ItemUseHandler> implements Recip
*
* @return the {@link EntityInteractHandler} of this {@link SlimefunItem}
*/
@Nonnull
public EntityInteractHandler onEntityInteract() {
return (e, item, offHand) -> {
if (!(e.getRightClicked() instanceof ItemFrame)) {