Skip to content

Commit

Permalink
Respect WorldlyContainer nullability contracts in SidedInvWrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
Technici4n committed Jan 12, 2025
1 parent dfba699 commit 8eba1c8
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public SidedInvWrapper(WorldlyContainer inv, @Nullable Direction side) {
}

public static int getSlot(WorldlyContainer inv, int slot, @Nullable Direction side) {
if (side == null) {
return slot;
}
int[] slots = inv.getSlotsForFace(side);
if (slot < slots.length)
return slots[slot];
Expand Down Expand Up @@ -74,6 +77,9 @@ public int hashCode() {

@Override
public int getSlots() {
if (side == null) {
return inv.getContainerSize();
}
return inv.getSlotsForFace(side).length;
}

Expand Down Expand Up @@ -181,7 +187,7 @@ public ItemStack extractItem(int slot, int amount, boolean simulate) {
if (stackInSlot.isEmpty())
return ItemStack.EMPTY;

if (!inv.canTakeItemThroughFace(slot1, stackInSlot, side))
if (side != null && !inv.canTakeItemThroughFace(slot1, stackInSlot, side))
return ItemStack.EMPTY;

if (simulate) {
Expand Down

0 comments on commit 8eba1c8

Please sign in to comment.