Browse Source

Blast Mining shouldn't drop Budding Amethyst
Fixes #4589

nossr50 3 years ago
parent
commit
6d9a9d165d
2 changed files with 22 additions and 24 deletions
  1. 1 0
      Changelog.txt
  2. 21 24
      src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java

+ 1 - 0
Changelog.txt

@@ -1,4 +1,5 @@
 Version 2.1.201
 Version 2.1.201
+    Blast Mining no longer drops Budding Amethyst since its not legal to obtain this item through normal gameplay
     Portuguese translation of Woodcutting changed back to Lenhador
     Portuguese translation of Woodcutting changed back to Lenhador
 
 
 Version 2.1.200
 Version 2.1.200

+ 21 - 24
src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java

@@ -26,11 +26,15 @@ import org.bukkit.entity.Player;
 import org.bukkit.entity.TNTPrimed;
 import org.bukkit.entity.TNTPrimed;
 import org.bukkit.event.entity.EntityExplodeEvent;
 import org.bukkit.event.entity.EntityExplodeEvent;
 import org.bukkit.inventory.ItemStack;
 import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.NotNull;
 
 
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.List;
 
 
 public class MiningManager extends SkillManager {
 public class MiningManager extends SkillManager {
+
+    public static final String BUDDING_AMETHYST = "budding_amethyst";
+
     public MiningManager(McMMOPlayer mcMMOPlayer) {
     public MiningManager(McMMOPlayer mcMMOPlayer) {
         super(mcMMOPlayer, PrimarySkillType.MINING);
         super(mcMMOPlayer, PrimarySkillType.MINING);
     }
     }
@@ -133,29 +137,6 @@ public class MiningManager extends SkillManager {
      * @param event The {@link EntityExplodeEvent}
      * @param event The {@link EntityExplodeEvent}
      */
      */
     //TODO: Rewrite this garbage
     //TODO: Rewrite this garbage
-    //TODO: Rewrite this garbage
-    //TODO: Rewrite this garbage
-    //TODO: Rewrite this garbage
-    //TODO: Rewrite this garbage
-    //TODO: Rewrite this garbage
-    //TODO: Rewrite this garbage
-    //TODO: Rewrite this garbage
-    //TODO: Rewrite this garbage
-    //TODO: Rewrite this garbage
-    //TODO: Rewrite this garbage
-    //TODO: Rewrite this garbage
-    //TODO: Rewrite this garbage
-    //TODO: Rewrite this garbage
-    //TODO: Rewrite this garbage
-    //TODO: Rewrite this garbage
-    //TODO: Rewrite this garbage
-    //TODO: Rewrite this garbage
-    //TODO: Rewrite this garbage
-    //TODO: Rewrite this garbage
-    //TODO: Rewrite this garbage
-    //TODO: Rewrite this garbage
-    //TODO: Rewrite this garbage
-    //TODO: Rewrite this garbage
     public void blastMiningDropProcessing(float yield, EntityExplodeEvent event) {
     public void blastMiningDropProcessing(float yield, EntityExplodeEvent event) {
         if (yield == 0)
         if (yield == 0)
             return;
             return;
@@ -181,19 +162,24 @@ public class MiningManager extends SkillManager {
         int xp = 0;
         int xp = 0;
 
 
         float oreBonus = (float) (getOreBonus() / 100);
         float oreBonus = (float) (getOreBonus() / 100);
-        //TODO: Pretty sure something is fucked with debrisReduction stuff
         float debrisReduction = (float) (getDebrisReduction() / 100);
         float debrisReduction = (float) (getDebrisReduction() / 100);
         int dropMultiplier = getDropMultiplier();
         int dropMultiplier = getDropMultiplier();
         float debrisYield = yield - debrisReduction;
         float debrisYield = yield - debrisReduction;
 
 
         //Drop "debris" based on skill modifiers
         //Drop "debris" based on skill modifiers
         for(BlockState blockState : notOres) {
         for(BlockState blockState : notOres) {
+            if(isDropIllegal(blockState.getType()))
+                continue;
+
             if(RandomUtils.nextFloat() < debrisYield) {
             if(RandomUtils.nextFloat() < debrisYield) {
                 Misc.spawnItem(getPlayer(), Misc.getBlockCenter(blockState), new ItemStack(blockState.getType()), ItemSpawnReason.BLAST_MINING_DEBRIS_NON_ORES); // Initial block that would have been dropped
                 Misc.spawnItem(getPlayer(), Misc.getBlockCenter(blockState), new ItemStack(blockState.getType()), ItemSpawnReason.BLAST_MINING_DEBRIS_NON_ORES); // Initial block that would have been dropped
             }
             }
         }
         }
 
 
         for (BlockState blockState : ores) {
         for (BlockState blockState : ores) {
+            if(isDropIllegal(blockState.getType()))
+                continue;
+
             if (RandomUtils.nextFloat() < (yield + oreBonus)) {
             if (RandomUtils.nextFloat() < (yield + oreBonus)) {
                 xp += Mining.getBlockXp(blockState);
                 xp += Mining.getBlockXp(blockState);
 
 
@@ -216,6 +202,17 @@ public class MiningManager extends SkillManager {
         applyXpGain(xp, XPGainReason.PVE);
         applyXpGain(xp, XPGainReason.PVE);
     }
     }
 
 
+    /**
+     * Checks if it would be illegal (in vanilla) to obtain the block
+     * Certain things should never drop ( such as budding_amethyst )
+     *
+     * @param material target material
+     * @return true if it's not legal to obtain the block through normal gameplay
+     */
+    public boolean isDropIllegal(@NotNull Material material) {
+        return material.getKey().getKey().equalsIgnoreCase(BUDDING_AMETHYST);
+    }
+
     /**
     /**
      * Increases the blast radius of the explosion.
      * Increases the blast radius of the explosion.
      *
      *