Skip to content

Commit

Permalink
fix: Item stack resurrection causing incorrect internal state of Lith…
Browse files Browse the repository at this point in the history
…iumStackList
  • Loading branch information
2No2Name committed Jun 20, 2024
1 parent 89b9a0b commit 737d5a3
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.jellysquid.mods.lithium.mixin.block.hopper;

import com.llamalad7.mixinextras.sugar.Local;
import me.jellysquid.mods.lithium.api.inventory.LithiumCooldownReceivingInventory;
import me.jellysquid.mods.lithium.api.inventory.LithiumInventory;
import me.jellysquid.mods.lithium.common.block.entity.SleepingBlockEntity;
Expand Down Expand Up @@ -822,4 +823,19 @@ private void checkSleepingConditions() {
sleepingBlockEntity.wakeUpNow();
}
}


//FIX for item stack revival issues
@Inject(
method = "extract(Lnet/minecraft/block/entity/Hopper;Lnet/minecraft/inventory/Inventory;ILnet/minecraft/util/math/Direction;)Z",
at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;setCount(I)V")
)
private static void replaceEmptyStackWithEmptyBeforeRevival(Hopper hopper, Inventory inventory, int slot, Direction side, CallbackInfoReturnable<Boolean> cir, @Local(ordinal = 0) ItemStack itemStack) {
if (itemStack.getCount() == 0) {
if (inventory instanceof LithiumInventory lithiumInventory) {
LithiumStackList lithiumStackList = InventoryHelper.getLithiumStackList(lithiumInventory);
lithiumStackList.set(slot, ItemStack.EMPTY);
}
}
}
}

0 comments on commit 737d5a3

Please sign in to comment.