From e85283776481ad47a24f4fc7cb6d43720ffca838 Mon Sep 17 00:00:00 2001 From: poma123 <25465545+poma123@users.noreply.github.com> Date: Wed, 30 Sep 2020 19:57:54 +0200 Subject: [PATCH] Added EntityInteractHandler cancellation --- .../implementation/items/tools/GoldPan.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/GoldPan.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/GoldPan.java index 2e7c09c60..0c7101673 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/GoldPan.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/GoldPan.java @@ -15,6 +15,7 @@ import io.github.thebusybiscuit.cscorelib2.collections.RandomizedSet; import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction; import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; +import io.github.thebusybiscuit.slimefun4.core.handlers.EntityInteractHandler; import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; @@ -47,6 +48,7 @@ public class GoldPan extends SimpleSlimefunItem implements Recip drops.addAll(getGoldPanDrops()); addItemSetting(drops.toArray(new GoldPanDrop[0])); + addItemHandler(onEntityInteract()); } protected Material getInput() { @@ -115,6 +117,16 @@ public class GoldPan extends SimpleSlimefunItem implements Recip }; } + /** + * This method cancels {@link EntityInteractHandler} to prevent interacting {@link GoldPan} + * with entities. + * + * @return the {@link EntityInteractHandler} of this {@link SlimefunItem} + */ + public EntityInteractHandler onEntityInteract() { + return (e, item, offHand) -> e.setCancelled(true); + } + @Override public List getDisplayRecipes() { List recipes = new LinkedList<>();