2
0
Эх сурвалжийг харах

blast mining no longer drops infested block variants

nossr50 2 сар өмнө
parent
commit
c2ecefb2a8

+ 3 - 0
Changelog.txt

@@ -1,3 +1,6 @@
+Version 2.2.032
+    Blast Mining no longer drops infested block variants
+
 Version 2.2.031
     Fixed potential NPE when player or blockstate is null for Inventory events on Furnaces
     Fixed bug where en_us locale was being set system-wide (thanks BlvckBytes)

+ 1 - 1
pom.xml

@@ -2,7 +2,7 @@
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.gmail.nossr50.mcMMO</groupId>
     <artifactId>mcMMO</artifactId>
-    <version>2.2.031</version>
+    <version>2.2.032-SNAPSHOT</version>
     <name>mcMMO</name>
     <url>https://github.com/mcMMO-Dev/mcMMO</url>
     <scm>

+ 13 - 10
src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java

@@ -28,10 +28,7 @@ import org.bukkit.event.entity.EntityExplodeEvent;
 import org.bukkit.inventory.ItemStack;
 import org.jetbrains.annotations.NotNull;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
 
 import static com.gmail.nossr50.util.ItemUtils.isPickaxe;
 
@@ -39,6 +36,9 @@ public class MiningManager extends SkillManager {
 
     public static final String BUDDING_AMETHYST = "budding_amethyst";
     public static final Collection<Material> BLAST_MINING_BLACKLIST = Set.of(Material.SPAWNER);
+    private final static Set<String> INFESTED_BLOCKS = Set.of("infested_stone", "infested_cobblestone",
+            "infested_stone_bricks", "infested_cracked_stone_bricks", "infested_mossy_stone_bricks",
+            "infested_chiseled_stone_bricks", "infested_deepslate");
 
     public MiningManager(@NotNull McMMOPlayer mcMMOPlayer) {
         super(mcMMOPlayer, PrimarySkillType.MINING);
@@ -164,9 +164,7 @@ public class MiningManager extends SkillManager {
 
         tnt.setMetadata(MetadataConstants.METADATA_KEY_TRACKED_TNT, mmoPlayer.getPlayerMetadata());
         tnt.setFuseTicks(0);
-        if (mcMMO.getCompatibilityManager().getMinecraftGameVersion().isAtLeast(1, 16, 4)) {
-            tnt.setSource(player);
-        }
+        tnt.setSource(player);
         targetBlock.setType(Material.AIR);
 
         mmoPlayer.setAbilityDATS(SuperAbilityType.BLAST_MINING, System.currentTimeMillis());
@@ -174,6 +172,10 @@ public class MiningManager extends SkillManager {
         mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(mmoPlayer.getPlayer(), new AbilityCooldownTask(mmoPlayer, SuperAbilityType.BLAST_MINING), (long) SuperAbilityType.BLAST_MINING.getCooldown() * Misc.TICK_CONVERSION_FACTOR);
     }
 
+    private boolean isInfestedBlock(String material) {
+        return INFESTED_BLOCKS.contains(material.toLowerCase(Locale.ENGLISH));
+    }
+
     /**
      * Handler for explosion drops and XP gain.
      *
@@ -255,13 +257,14 @@ public class MiningManager extends SkillManager {
 
     /**
      * Checks if it would be illegal (in vanilla) to obtain the block
-     * Certain things should never drop ( such as budding_amethyst )
+     * Certain things should never drop (such as budding_amethyst and infested blocks)
      *
      * @param material target material
-     * @return true if it's not legal to obtain the block through normal gameplay
+     * @return true if it's not legal to get the block through normal gameplay
      */
     public boolean isDropIllegal(@NotNull Material material) {
-        return material.getKey().getKey().equalsIgnoreCase(BUDDING_AMETHYST);
+        return isInfestedBlock(material.getKey().getKey())
+                || material.getKey().getKey().equalsIgnoreCase(BUDDING_AMETHYST);
     }
 
     /**