From cc05d1cad193951c215cf8b7caaaaf4e3aa43ff1 Mon Sep 17 00:00:00 2001 From: RoboMWM Date: Sat, 19 Oct 2019 09:22:11 -0700 Subject: [PATCH] check for refill when interacting with entities (e.g. feeding animals) Closes #9 --- src/me/ryanhamshire/AutomaticInventory/AIEventHandler.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/me/ryanhamshire/AutomaticInventory/AIEventHandler.java b/src/me/ryanhamshire/AutomaticInventory/AIEventHandler.java index a4f9703..d2e4a05 100644 --- a/src/me/ryanhamshire/AutomaticInventory/AIEventHandler.java +++ b/src/me/ryanhamshire/AutomaticInventory/AIEventHandler.java @@ -91,6 +91,13 @@ public void onProjectileLaunch(ProjectileLaunchEvent event) tryRefillStackInHand(player, EquipmentSlot.HAND, false); } + @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) + public void onFeedAnimal(PlayerInteractEntityEvent event) + { + Player player = event.getPlayer(); + tryRefillStackInHand(player, event.getHand(), true); + } + private void tryRefillStackInHand(Player player, EquipmentSlot slot, boolean dataValueMatters) { if(slot == null) return;