Skip to content

Commit

Permalink
Enforce safe stack copying, fixes #593
Browse files Browse the repository at this point in the history
  • Loading branch information
ACGaming committed Nov 21, 2024
1 parent aa0df7d commit 3fa1cae
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,14 @@ private static boolean isStackEmpty(ItemStack stack)

private static ItemStack safeCopy(ItemStack stack)
{
return stack.copy();
try
{
return stack.copy();
}
catch (Exception e)
{
return ItemStack.EMPTY;
}
}

private final List<ChangeInfo> changeEntries = Lists.newArrayList();
Expand Down Expand Up @@ -291,12 +298,12 @@ public void utPUNClientTick(TickEvent.ClientTickEvent event)
ItemStack stack = player.inventory.getStackInSlot(i);
ItemStack old = previous[i];
if (isChangeMeaningful(old, stack)) changes.add(Pair.of(old, stack));
previous[i] = stack.copy();
previous[i] = safeCopy(stack);
}

ItemStack stackInCursor = player.inventory.getItemStack();
if (isChangeMeaningful(stackInCursor, previousInCursor)) changes.add(Pair.of(previousInCursor, stackInCursor));
previousInCursor = stackInCursor.copy();
previousInCursor = safeCopy(stackInCursor);

if (UTConfigTweaks.MISC.PICKUP_NOTIFICATION.utPUNExperience)
{
Expand Down

0 comments on commit 3fa1cae

Please sign in to comment.