Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect WorldlyContainer nullability contracts in SidedInvWrapper #1847

Draft
wants to merge 1 commit into
base: 1.21.x
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading