Skip to content

Commit

Permalink
Fix crash
Browse files Browse the repository at this point in the history
  • Loading branch information
Oxyopiia committed Apr 28, 2024
1 parent f8d0235 commit b83ab13
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/main/java/net/oxyopia/vice/mixin/MixinHandledScreen.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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);
}
}

Expand Down

0 comments on commit b83ab13

Please sign in to comment.