From 584177904a2433e752d6f929b6b554f524edd64f Mon Sep 17 00:00:00 2001 From: Waiting Idly <25394029+WaitingIdly@users.noreply.github.com> Date: Tue, 3 Dec 2024 11:04:25 -0800 Subject: [PATCH] check that the inventory is `InventoryCraftResult` (#274) --- .../java/com/cleanroommc/groovyscript/event/EventHandler.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/cleanroommc/groovyscript/event/EventHandler.java b/src/main/java/com/cleanroommc/groovyscript/event/EventHandler.java index 39130c913..99f81c5b4 100644 --- a/src/main/java/com/cleanroommc/groovyscript/event/EventHandler.java +++ b/src/main/java/com/cleanroommc/groovyscript/event/EventHandler.java @@ -127,8 +127,8 @@ public static void onItemCrafted(PlayerEvent.ItemCraftedEvent event) { Container container = ((InventoryCraftingAccess) inventoryCrafting).getEventHandler(); if (container != null) { for (Slot slot : container.inventorySlots) { - if (slot instanceof SlotCrafting) { - craftResult = (InventoryCraftResult) slot.inventory; + if (slot instanceof SlotCrafting && slot.inventory instanceof InventoryCraftResult result) { + craftResult = result; player = ((SlotCraftingAccess) slot).getPlayer(); break; }