Skip to content

Commit

Permalink
Fix onSlotClick with invalid index crashing game
Browse files Browse the repository at this point in the history
  • Loading branch information
johnpgr committed May 30, 2024
1 parent 59755e5 commit f324aa2
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ class CraftingTableIIScreenHandler(
}
}

override fun isValid(slot: Int): Boolean {
return slot >= 0 && slot < this.slots.size
}

override fun onSlotClick(
slotIndex: Int, button: Int, actionType: SlotActionType, player: PlayerEntity
) {
Expand All @@ -98,7 +102,7 @@ class CraftingTableIIScreenHandler(
if(button != 0) return

if (player.world.isClient) {
if (slotIndex == -999) return
if (!this.isValid(slotIndex)) return
val slot = this.getSlot(slotIndex)
if (!slot.hasStack()) return

Expand Down

0 comments on commit f324aa2

Please sign in to comment.