3232import com .gmail .nossr50 .util .sounds .SoundType ;
3333import com .gmail .nossr50 .worldguard .WorldGuardManager ;
3434import com .gmail .nossr50 .worldguard .WorldGuardUtils ;
35+ import java .util .Collection ;
3536import java .util .HashSet ;
3637import java .util .List ;
3738import java .util .Set ;
@@ -121,15 +122,25 @@ public void onBlockDropItemEvent(BlockDropItemEvent event) {
121122 final MetadataValue bonusDropMeta = block
122123 .getMetadata (METADATA_KEY_BONUS_DROPS ).get (0 );
123124 if (blockCount <= 1 ) {
125+ // Get the base drops (without Fortune/enchantments) to calculate bonus properly
126+ // This runs at LOWEST priority, so Fortune has already been applied
127+ final Player player = event .getPlayer ();
128+ final ItemStack tool = player .getInventory ().getItemInMainHand ();
129+ final ItemStack toolWithoutEnchants = tool .clone ();
130+
131+ // Remove all enchantments from the cloned tool
132+ toolWithoutEnchants .getEnchantments ().keySet ().forEach (toolWithoutEnchants ::removeEnchantment );
133+
134+ final Collection <ItemStack > baseDrops = block .getDrops (toolWithoutEnchants );
135+
124136 for (final Item item : eventItems ) {
125137 final ItemStack eventItemStack = item .getItemStack ();
126- int originalAmount = eventItemStack .getAmount ();
127-
138+ final Material itemType = eventItemStack .getType ();
139+
128140 if (eventItemStack .getAmount () <= 0 ) {
129141 continue ;
130142 }
131143
132- final Material itemType = eventItemStack .getType ();
133144 if (!mcMMO .p .getGeneralConfig ()
134145 .getDoubleDropsEnabled (PrimarySkillType .MINING , itemType )
135146 && !mcMMO .p .getGeneralConfig ()
@@ -146,9 +157,26 @@ public void onBlockDropItemEvent(BlockDropItemEvent event) {
146157 }
147158 }
148159
149- int amountToAddFromBonus = bonusDropMeta .asInt ();
160+ // Find the base amount for this item type (before Fortune)
161+ int baseAmount = 0 ;
162+ for (ItemStack baseDrop : baseDrops ) {
163+ if (baseDrop .getType () == itemType ) {
164+ baseAmount = baseDrop .getAmount ();
165+ break ;
166+ }
167+ }
168+
169+ // Calculate bonus based on the BASE amount, not the Fortune-modified amount
170+ // Since we're at LOWEST priority, other plugins have already modified the drops
171+ // So we add our bonus based on the vanilla base amount
172+ int bonusMultiplier = bonusDropMeta .asInt ();
173+ int bonusToAdd = baseAmount * bonusMultiplier ;
174+
175+ int originalAmount = eventItemStack .getAmount ();
176+ int newAmount = originalAmount + bonusToAdd ;
177+
150178 final McMMOModifyBlockDropItemEvent modifyBlockDropItemEvent
151- = new McMMOModifyBlockDropItemEvent (event , item , amountToAddFromBonus );
179+ = new McMMOModifyBlockDropItemEvent (event , item , newAmount );
152180 plugin .getServer ().getPluginManager ().callEvent (modifyBlockDropItemEvent );
153181 if (!modifyBlockDropItemEvent .isCancelled ()
154182 && modifyBlockDropItemEvent .getModifiedItemStackQuantity () > originalAmount ) {
0 commit comments