فهرست منبع

Green Thumb (Plants) now fires a SubSkillBlockEvent

nossr50 4 سال پیش
والد
کامیت
369b34406e
2فایلهای تغییر یافته به همراه12 افزوده شده و 5 حذف شده
  1. 2 0
      Changelog.txt
  2. 10 5
      src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java

+ 2 - 0
Changelog.txt

@@ -5,9 +5,11 @@ Version 2.1.174
     Updated fr locale (thanks Elikill58)
     (API) Added SubSkillBlockEvent for some SubSkill events that have a block (eg: Green Thumb Block events)
     (API) Green Thumb (Block) now fires a SubSkillBlockEvent which is cancellable
+    (API) Green Thumb (Plant) now fires SubSkillBlockEvent which is cancellable
     (API) Shroom Thumb now fires a SubSkillBlockEvent which is cancellable
 
     NOTE: A lot of sub-skills without random chance elements are missing events, this will be cleaned up in the near future. If you need something specific added sooner than that, post a GitHub issue for it and I'll patch it in.
+    I'm likely to separate Green Thumb into two distinct skills in an upcoming patch
 
 Version 2.1.173
     The experience orbs dropped by Knock on Wood rank 2 during Tree Feller are now much less frequent but provide more XP

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

@@ -754,11 +754,16 @@ public class HerbalismManager extends SkillManager {
             return false;
         }
 
-        playerInventory.removeItem(seedStack);
-        player.updateInventory(); // Needed until replacement available
-        //Play sound
-        SoundManager.sendSound(player, player.getLocation(), SoundType.ITEM_CONSUMED);
-        return true;
+        if(EventUtils.callSubSkillBlockEvent(player, SubSkillType.HERBALISM_GREEN_THUMB, blockState.getBlock()).isCancelled()) {
+            return false;
+        } else {
+            playerInventory.removeItem(seedStack);
+            player.updateInventory(); // Needed until replacement available
+            //Play sound
+            SoundManager.sendSound(player, player.getLocation(), SoundType.ITEM_CONSUMED);
+            return true;
+        }
+
 //        new HerbalismBlockUpdaterTask(blockState).runTaskLater(mcMMO.p, 0);
     }