From b83ab1314f48dfca5defde36e955d5ac2ac00d02 Mon Sep 17 00:00:00 2001 From: Oxyopiia Date: Sun, 28 Apr 2024 20:17:38 +0100 Subject: [PATCH] Fix crash --- .../net/oxyopia/vice/mixin/MixinHandledScreen.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/oxyopia/vice/mixin/MixinHandledScreen.java b/src/main/java/net/oxyopia/vice/mixin/MixinHandledScreen.java index 03609dc2..4fce2cf5 100644 --- a/src/main/java/net/oxyopia/vice/mixin/MixinHandledScreen.java +++ b/src/main/java/net/oxyopia/vice/mixin/MixinHandledScreen.java @@ -1,5 +1,6 @@ package net.oxyopia.vice.mixin; +import com.mojang.logging.LogUtils; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.Screen; @@ -84,10 +85,15 @@ private void onAttemptMoveItem(ClientPlayerInteractionManager instance, int sync if (actionType == SlotActionType.THROW) { MinecraftClient client = MinecraftClient.getInstance(); - ItemStack item = client.player != null ? client.player.currentScreenHandler.getSlot(slotId).getStack() : null; + try { + ItemStack item = client.player != null ? client.player.currentScreenHandler.getSlot(slotId).getStack() : null; - if (item != null) { - result = EVENT_MANAGER.publish(new ItemDropEvent(item)); + if (item != null) { + result = EVENT_MANAGER.publish(new ItemDropEvent(item)); + } + + } catch (Exception error) { + LogUtils.getLogger().warn("An error occurred getting an ItemStack in a slot thrown event! slotId {} button {} syncId {} actionType {} title {}", slotId, button, syncId, actionType, title.getString(), error); } }