Make crafting stations slots use ISidedInventory/IInventory validation logic (#48)

* Update buildscript

* Update dependencies

* Make crafting stations slots use ISidedInventory/IInventory validation logic

* Fix handling of inventories with inaccessible slots
This commit is contained in:
Jakub Szewczyk authored and GitHub committed 2022-05-14 11:22:11 +02:00
1 parent 6ae7c13408
commit e9cacb5e37
5 files changed
+62 -28

No files matched your search

@@ -92,7 +92,8 @@ public class CraftingStationContainer extends Container {
IInventory inv = logic.getFirstInventory();
IInventory secondInv = logic.getSecondInventory();
final Set<Integer> accessibleSlots = inv instanceof ISidedInventory ? new HashSet<>(Ints.asList(((ISidedInventory) inv).getAccessibleSlotsFromSide(logic.chestDirection.getOpposite().ordinal()))) : null;
final int accessSide = logic.chestDirection.getOpposite().ordinal();
final int[] accessibleSlots = inv instanceof ISidedInventory ? ((ISidedInventory) inv).getAccessibleSlotsFromSide(accessSide) : null;
int index = 0, curIndex = 0;
IInventory curInv;
@@ -104,10 +105,16 @@ public class CraftingStationContainer extends Container {
curInv = secondInv != null && index >= 27 ? secondInv : inv;
// Adjust the index for the inventory
curIndex = secondInv != null && index >= 27 ? index - 27 : index;
if(accessibleSlots == null || accessibleSlots.contains(curIndex)) {
this.addSlotToContainer(new ChestSlot(curInv, curIndex, 8 + col * 18, 19 + row * 18));
if(accessibleSlots != null) {
if (curIndex >= accessibleSlots.length) {
break;
} else {
curIndex = accessibleSlots[curIndex];
}
}
this.addSlotToContainer(new ChestSlot(curInv, curIndex, index, 8 + col * 18, 19 + row * 18, accessSide));
index++;
}
}