From fea8d1f0f1bf6de4c5e0f028dcc3c92ae4d9bc53 Mon Sep 17 00:00:00 2001 From: Th3Shadowbroker Date: Sat, 13 Mar 2021 13:33:26 +0100 Subject: [PATCH 1/2] Fixed a bug that caused drops to be handled incorrectly --- .../ouroboros/mines/drops/DropGroup.java | 6 +++-- .../mines/listeners/BlockBreakListener.java | 22 ++++++++++--------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/main/java/dev/th3shadowbroker/ouroboros/mines/drops/DropGroup.java b/src/main/java/dev/th3shadowbroker/ouroboros/mines/drops/DropGroup.java index a156672..621b076 100644 --- a/src/main/java/dev/th3shadowbroker/ouroboros/mines/drops/DropGroup.java +++ b/src/main/java/dev/th3shadowbroker/ouroboros/mines/drops/DropGroup.java @@ -20,6 +20,7 @@ package dev.th3shadowbroker.ouroboros.mines.drops; import dev.th3shadowbroker.ouroboros.mines.drops.types.AbstractDrop; +import dev.th3shadowbroker.ouroboros.mines.drops.types.ItemDrop; import org.bukkit.Location; import org.bukkit.entity.Player; @@ -57,7 +58,8 @@ public AbstractDrop[] drawMultidrop() { drops.add(drop); } else { Random rnd = new Random(); - boolean shallDrop = ((double) rnd.nextInt(100) / 100) <= drop.getChance(); + double drawn = ((double) rnd.nextInt(100) / 100); + boolean shallDrop = drawn <= drop.getChance(); if (shallDrop) drops.add(drop); } }); @@ -73,7 +75,7 @@ public AbstractDrop drawSingledrop() { double offset = 0; for (AbstractDrop pDrop : drops) { - boolean shallDrop = pDrop.getChance() <= drawn + offset; + boolean shallDrop = pDrop.getChance() >= 1 || pDrop.getChance() <= drawn + offset; if (shallDrop) { drop = pDrop; break; diff --git a/src/main/java/dev/th3shadowbroker/ouroboros/mines/listeners/BlockBreakListener.java b/src/main/java/dev/th3shadowbroker/ouroboros/mines/listeners/BlockBreakListener.java index 91e042e..736c158 100644 --- a/src/main/java/dev/th3shadowbroker/ouroboros/mines/listeners/BlockBreakListener.java +++ b/src/main/java/dev/th3shadowbroker/ouroboros/mines/listeners/BlockBreakListener.java @@ -149,16 +149,18 @@ private void breakBlock(BlockBreakEvent event, MineableMaterial mineableMaterial } private void breakNaturally(BlockBreakEvent event, boolean dropNaturalItems, boolean autoPickup) { - if (autoPickup) { - event.setDropItems(dropNaturalItems); - Collection drops = event.getBlock().getDrops(); - - Player player = event.getPlayer(); - Location blockLocation = event.getBlock().getLocation(); - Map overflow = player.getInventory().addItem(drops.stream().toArray(ItemStack[]::new)); - overflow.values().forEach(i -> blockLocation.getWorld().dropItem(blockLocation, i)); - } else { - event.getBlock().breakNaturally(event.getPlayer().getInventory().getItemInMainHand()); + if (dropNaturalItems) { + if (autoPickup) { + event.setDropItems(false); + Collection drops = event.getBlock().getDrops(); + + Player player = event.getPlayer(); + Location blockLocation = event.getBlock().getLocation(); + Map overflow = player.getInventory().addItem(drops.stream().toArray(ItemStack[]::new)); + overflow.values().forEach(i -> blockLocation.getWorld().dropItem(blockLocation, i)); + } else { + event.getBlock().breakNaturally(event.getPlayer().getInventory().getItemInMainHand()); + } } } From 54a77d09b267db075b1779cb1556c20317d30f27 Mon Sep 17 00:00:00 2001 From: Th3Shadowbroker Date: Sat, 20 Mar 2021 08:15:00 +0100 Subject: [PATCH 2/2] Bumped 1.10.1 -> 1.10.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 122897e..e536d59 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ dev.th3shadowbroker.spigot OuroborosMines - 1.10.1-SNAPSHOT + 1.10.2-SNAPSHOT ${project.artifactId}