Explorar o código

Berserk now breaks a soft block if it was used to activate it

nossr50 %!s(int64=5) %!d(string=hai) anos
pai
achega
15d3119627

+ 2 - 0
Changelog.txt

@@ -1,5 +1,7 @@
 Version 2.1.113
+    Activating Berserk on a soft block (glass, snow, dirts) will break that material right away instead of only breaking subsequent blocks hit by the player
     Berserk will now break glass and glass pane blocks
+    Hitting glass with berserk readied will activate it
     Added GLASS settings to sounds.yml for Berserk
     Fixed bug where BlockCracker didn't work on infested_stone_bricks
     Fixed a bug where beacons could be duplicated

+ 0 - 1
src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java

@@ -849,7 +849,6 @@ public class McMMOPlayer {
             return;
         }
 
-
         //TODO: This is hacky and temporary solution until skills are move to the new system
         //Potential problems with this include skills with two super abilities (ie mining)
         if(!skill.isSuperAbilityUnlocked(getPlayer()))

+ 18 - 3
src/main/java/com/gmail/nossr50/listeners/BlockListener.java

@@ -512,8 +512,23 @@ public class BlockListener implements Listener {
             else if (mcMMOPlayer.getToolPreparationMode(ToolType.SHOVEL) && ItemUtils.isShovel(heldItem) && BlockUtils.affectedByGigaDrillBreaker(blockState) && Permissions.gigaDrillBreaker(player)) {
                 mcMMOPlayer.checkAbilityActivation(PrimarySkillType.EXCAVATION);
             }
-            else if (mcMMOPlayer.getToolPreparationMode(ToolType.FISTS) && heldItem.getType() == Material.AIR && (BlockUtils.affectedByGigaDrillBreaker(blockState) || blockState.getType() == Material.SNOW || BlockUtils.affectedByBlockCracker(blockState) && Permissions.berserk(player))) {
+            else if (mcMMOPlayer.getToolPreparationMode(ToolType.FISTS) && heldItem.getType() == Material.AIR && (BlockUtils.affectedByGigaDrillBreaker(blockState)
+                    || mcMMO.getMaterialMapStore().isGlass(blockState.getType())
+                    || blockState.getType() == Material.SNOW
+                    || BlockUtils.affectedByBlockCracker(blockState) && Permissions.berserk(player))) {
                 mcMMOPlayer.checkAbilityActivation(PrimarySkillType.UNARMED);
+
+                if(mcMMOPlayer.getAbilityMode(SuperAbilityType.BERSERK)) {
+                    if (SuperAbilityType.BERSERK.blockCheck(blockState) && EventUtils.simulateBlockBreak(blockState.getBlock(), player, true)) {
+                        event.setInstaBreak(true);
+
+                        if(blockState.getType().getKey().getKey().contains("glass")) {
+                            SoundManager.worldSendSound(player.getWorld(), blockState.getLocation(), SoundType.GLASS);
+                        } else {
+                            SoundManager.sendSound(player, blockState.getLocation(), SoundType.POP);
+                        }
+                    }
+                }
             }
         }
 
@@ -593,10 +608,10 @@ public class BlockListener implements Listener {
                     blockState.update();
                 }
             }
-            else if (SuperAbilityType.BERSERK.blockCheck(block.getState()) && EventUtils.simulateBlockBreak(block, player, true)) {
+            else if (!event.getInstaBreak() && SuperAbilityType.BERSERK.blockCheck(blockState) && EventUtils.simulateBlockBreak(block, player, true)) {
                 event.setInstaBreak(true);
 
-                if(block.getState().getType().getKey().getKey().contains("glass")) {
+                if(blockState.getType().getKey().getKey().contains("glass")) {
                     SoundManager.worldSendSound(player.getWorld(), block.getLocation(), SoundType.GLASS);
                 } else {
                     SoundManager.sendSound(player, block.getLocation(), SoundType.POP);