Skip to content

Commit

Permalink
Packing irl
Browse files Browse the repository at this point in the history
- Default packager unwrapping behaviour uses more robust insertion method when not in a simulation #7426
  • Loading branch information
simibubi committed Mar 5, 2025
1 parent cef2b16 commit 8662470
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ dependencies {
// modRuntimeOnly("curse.maven:windsweptmod-636321:4817132")
// modRuntimeOnly("curse.maven:good-ending-690161:4363719")
// modRuntimeOnly("curse.maven:inventory-sorter-240633:5979609")
// modRuntimeOnly("curse.maven:sophisticated-storage-619320:6217888")
// modRuntimeOnly("curse.maven:sophisticated-core-618298:6266807")

// https://discord.com/channels/313125603924639766/725850371834118214/910619168821354497
// Prevent Mixin annotation processor from getting into IntelliJ's annotation processor settings
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ flywheel_minecraft_version = 1.20.1
flywheel_version = 1.0.1
vanillin_version = 1.0.0-beta-217
jei_minecraft_version = 1.20.1
jei_version = 15.19.0.85
jei_version = 15.19.5.99
curios_minecraft_version = 1.20.1
curios_version = 5.3.1
ponder_version = 1.0.45
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,20 @@ public boolean unpack(Level level, BlockPos pos, BlockState state, Direction sid
IItemHandler targetInv = targetBE.getCapability(ForgeCapabilities.ITEM_HANDLER, side).resolve().orElse(null);
if (targetInv == null)
return false;

if (!simulate) {
/*
* Some mods do not support slot-by-slot precision during simulate = false.
* Faulty interactions may lead to voiding of items, but the simulate pass should
* already have correctly identified there to be enough space for everything.
*/
for (ItemStack itemStack : items)
ItemHandlerHelper.insertItemStacked(targetInv, itemStack.copy(), false);
return true;
}

for (int slot = 0; slot < targetInv.getSlots(); slot++) {
ItemStack itemInSlot = targetInv.getStackInSlot(slot);
if (!simulate)
itemInSlot = itemInSlot.copy();

int itemsAddedToSlot = 0;

for (int boxSlot = 0; boxSlot < items.size(); boxSlot++) {
Expand All @@ -56,9 +64,6 @@ public boolean unpack(Level level, BlockPos pos, BlockState state, Direction sid
items.set(boxSlot, ItemStack.EMPTY);

itemInSlot = toInsert;
if (!simulate)
itemInSlot = itemInSlot.copy();

targetInv.insertItem(slot, toInsert, simulate);
continue;
}
Expand Down

0 comments on commit 8662470

Please sign in to comment.