Fix crafting
This commit is contained in:
@@ -132,6 +132,7 @@ public class HardDrive {
|
||||
} else {
|
||||
entry.setValue(countInDrive - outCount);
|
||||
outCount -= countInDrive;
|
||||
outCount = Math.max(outCount, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@@ -210,13 +210,15 @@ public class StorageNetwork {
|
||||
ItemStack outStack = stackToRemove.copy();
|
||||
|
||||
for (HardDrive drive : drives) {
|
||||
ItemStack removedStack = drive.removeStackFromInventoryRemains(outStack);
|
||||
if (removedStack.getCount() <= 0) {
|
||||
break;
|
||||
outStack = drive.removeStackFromInventoryRemains(outStack);
|
||||
if (outStack.getCount() <= 0) {
|
||||
// If all items are removed, return an empty stack
|
||||
return ItemStack.EMPTY; // Assuming ItemStack.EMPTY represents an empty stack
|
||||
}
|
||||
}
|
||||
|
||||
// If we still have remaining items, return false
|
||||
// Return the remaining stack if some items could not be removed
|
||||
return outStack;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -171,13 +171,11 @@ public class CraftingScreen extends PagedGui {
|
||||
|
||||
private void removeItems(ItemStack stack) {
|
||||
ItemStack removedFromStorage = this.blockEntity.network.removeItemStack(stack);
|
||||
ItemStack fromPlayer = stack.copy();
|
||||
fromPlayer.setCount(stack.getCount() - removedFromStorage.getCount());
|
||||
if (fromPlayer.getCount() > 0) {
|
||||
if (removedFromStorage.getCount() > 0) {
|
||||
Inventory playerInventory = player.getInventory();
|
||||
for (int i = 0; i < playerInventory.size(); i++) {
|
||||
if (ItemStack.areItemsEqual(playerInventory.getStack(i), fromPlayer)) {
|
||||
playerInventory.removeStack(i, fromPlayer.getCount());
|
||||
if (ItemStack.areItemsEqual(playerInventory.getStack(i), removedFromStorage)) {
|
||||
playerInventory.removeStack(i, removedFromStorage.getCount());
|
||||
break; // Only remove one stack per crafting iteration
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user