Skip to content

Commit

Permalink
Fabric: Check slot index for cursorItem
Browse files Browse the repository at this point in the history
Closes #9
  • Loading branch information
hpfxd committed Jul 2, 2024
1 parent 5903f80 commit fb5f570
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public abstract class AbstractContainerScreenMixin {
if (cursorSlot != -1 && this.cursorSlot != -1 && this.cursorSlot != cursorSlot) {
final ItemStack animationItem = this.cursorItem.isEmpty() ? cursorItem : this.cursorItem;

if (!animationItem.isEmpty()) {
if (!animationItem.isEmpty() && this.menu.isValidSlotIndex(this.cursorSlot) && this.menu.isValidSlotIndex(cursorSlot)) {
this.animations.add(new ItemMoveAnimation(this.cursorSlot, cursorSlot, animationItem));
}
}
Expand All @@ -111,7 +111,7 @@ public abstract class AbstractContainerScreenMixin {
this.spectatorplus$renderCursorItem(guiGraphics, animation.itemStack, cursorX, cursorY);
}

if (!this.cursorItem.isEmpty() && this.cursorSlot > 0) {
if (!this.cursorItem.isEmpty() && this.cursorSlot > 0 && this.menu.isValidSlotIndex(this.cursorSlot)) {
final Slot slot = this.menu.getSlot(this.cursorSlot);
this.spectatorplus$renderCursorItem(guiGraphics, this.cursorItem, slot.x, slot.y);
}
Expand Down

0 comments on commit fb5f570

Please sign in to comment.