save nbt data while materialgrabbing

This commit is contained in:
ForestOfLight
2025-12-29 22:35:40 -08:00
Unverified
parent f561d281ee
commit d72156b533
+4 -2
View File
@@ -140,7 +140,8 @@ function playSoundEffect(player, transferCount) {
function tryTransferAmountToPlayer(slot, playerContainer, materials, grabAmount) {
const itemStack = slot.getItem();
if (canAddItem(playerContainer, itemStack)) {
const itemStackToAdd = new ItemStack(itemStack.typeId, grabAmount);
const itemStackToAdd = itemStack.clone();
itemStackToAdd.amount = grabAmount;
addItem(playerContainer, itemStackToAdd);
materials.remove(itemStack.typeId, grabAmount);
removeAmount(slot, grabAmount);
@@ -185,7 +186,8 @@ function partiallyFilledSlotPass(inventory, itemStack) {
const remainderAmount = Math.max(0, (slot.amount + itemStack.amount) - slot.maxAmount);
slot.amount += itemStack.amount - remainderAmount;
if (remainderAmount > 0) {
const remainderStack = new ItemStack(itemStack.typeId, remainderAmount);
const remainderStack = itemStack.clone();
remainderStack.amount = remainderAmount;
addItem(inventory, remainderStack);
}
return true;