瀏覽代碼

Green Thumb requires a hoe, sneak to break with a hoe

nossr50 5 年之前
父節點
當前提交
7c6d5c476d

+ 2 - 0
Changelog.txt

@@ -1,4 +1,6 @@
 Version 2.1.115
+    Green Thumb now requires a hoe to activate
+    You can sneak to break plants with a hoe in your hand (or just put the hoe away)
     Hoes no longer give free replants
     There is now a feature in place to prevent breaking a newly automatically replanted (via green thumb) crop from being breakable for a few seconds after it appears
     Using a hoe on non-fully grown crops will replant them as a convenience feature for those who can't bother to wait for all of their plants to grow (put away the hoe to break non-fully grown crops)

+ 10 - 4
src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java

@@ -26,6 +26,8 @@ import com.gmail.nossr50.util.random.RandomChanceUtil;
 import com.gmail.nossr50.util.skills.RankUtils;
 import com.gmail.nossr50.util.skills.SkillActivationType;
 import com.gmail.nossr50.util.skills.SkillUtils;
+import com.gmail.nossr50.util.sounds.SoundManager;
+import com.gmail.nossr50.util.sounds.SoundType;
 import org.bukkit.Location;
 import org.bukkit.Material;
 import org.bukkit.block.Block;
@@ -667,17 +669,19 @@ public class HerbalismManager extends SkillManager {
      * @param greenTerra boolean to determine if greenTerra is active or not
      */
     private void processGreenThumbPlants(BlockState blockState, BlockBreakEvent blockBreakEvent, boolean greenTerra) {
+        if(blockBreakEvent.getPlayer().isSneaking() || !ItemUtils.isHoe(blockBreakEvent.getPlayer().getInventory().getItemInMainHand())) {
+            return;
+        }
+
         BlockData blockData = blockState.getBlockData();
 
-        if (!(blockData instanceof Ageable))
+        if (!(blockData instanceof Ageable)) {
             return;
+        }
 
         Ageable ageable = (Ageable) blockData;
 
         //If the ageable is NOT mature and the player is NOT using a hoe, abort
-        if(!isAgeableMature(ageable) && !ItemUtils.isHoe(getPlayer().getItemInHand())) {
-            return;
-        }
 
         Player player = getPlayer();
         PlayerInventory playerInventory = player.getInventory();
@@ -729,6 +733,8 @@ public class HerbalismManager extends SkillManager {
 
         playerInventory.removeItem(seedStack);
         player.updateInventory(); // Needed until replacement available
+        //Play sound
+        SoundManager.sendSound(player, player.getLocation(), SoundType.ITEM_CONSUMED);
 
         new HerbalismBlockUpdaterTask(blockState).runTaskLater(mcMMO.p, 0);
     }

+ 2 - 0
src/main/java/com/gmail/nossr50/util/sounds/SoundManager.java

@@ -98,6 +98,8 @@ public class SoundManager {
                 return Sound.ENTITY_ENDER_EYE_DEATH;
             case GLASS:
                 return Sound.BLOCK_GLASS_BREAK;
+            case ITEM_CONSUMED:
+                return Sound.ITEM_BOTTLE_EMPTY;
             default:
                 return null;
         }

+ 1 - 0
src/main/java/com/gmail/nossr50/util/sounds/SoundType.java

@@ -15,6 +15,7 @@ public enum SoundType {
     ABILITY_ACTIVATED_BERSERK,
     BLEED,
     GLASS,
+    ITEM_CONSUMED,
     TIRED;
 
     public boolean usesCustomPitch()

+ 4 - 0
src/main/resources/sounds.yml

@@ -4,6 +4,10 @@ Sounds:
     # 1.0 = Max volume
     # 0.0 = No Volume
     MasterVolume: 1.0
+    ITEM_CONSUMED:
+        Enable: true
+        Volume: 1.0
+        Pitch: 1.0
     GLASS:
         Enable: true
         Volume: 1.0