Fix crafting
This commit is contained in:
parent
6bdacc88fa
commit
42f37ea5df
@ -4,14 +4,14 @@ org.gradle.jvmargs=-Xmx1G
|
|||||||
# check these on https://modmuss50.me/fabric.html
|
# check these on https://modmuss50.me/fabric.html
|
||||||
|
|
||||||
minecraft_version=1.21
|
minecraft_version=1.21
|
||||||
yarn_mappings=1.21+build.8
|
yarn_mappings=1.21+build.9
|
||||||
loader_version=0.15.11
|
loader_version=0.16.0
|
||||||
|
|
||||||
# Fabric API
|
# Fabric API
|
||||||
fabric_version=0.100.6+1.21
|
fabric_version=0.100.6+1.21
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version=3.1.0
|
mod_version=3.1.1
|
||||||
maven_group=systems.brn
|
maven_group=systems.brn
|
||||||
archives_base_name=Serverstorage
|
archives_base_name=Serverstorage
|
||||||
|
|
||||||
|
@ -132,6 +132,7 @@ public class HardDrive {
|
|||||||
} else {
|
} else {
|
||||||
entry.setValue(countInDrive - outCount);
|
entry.setValue(countInDrive - outCount);
|
||||||
outCount -= countInDrive;
|
outCount -= countInDrive;
|
||||||
|
outCount = Math.max(outCount, 0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -210,13 +210,15 @@ public class StorageNetwork {
|
|||||||
ItemStack outStack = stackToRemove.copy();
|
ItemStack outStack = stackToRemove.copy();
|
||||||
|
|
||||||
for (HardDrive drive : drives) {
|
for (HardDrive drive : drives) {
|
||||||
ItemStack removedStack = drive.removeStackFromInventoryRemains(outStack);
|
outStack = drive.removeStackFromInventoryRemains(outStack);
|
||||||
if (removedStack.getCount() <= 0) {
|
if (outStack.getCount() <= 0) {
|
||||||
break;
|
// 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;
|
return outStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -171,13 +171,11 @@ public class CraftingScreen extends PagedGui {
|
|||||||
|
|
||||||
private void removeItems(ItemStack stack) {
|
private void removeItems(ItemStack stack) {
|
||||||
ItemStack removedFromStorage = this.blockEntity.network.removeItemStack(stack);
|
ItemStack removedFromStorage = this.blockEntity.network.removeItemStack(stack);
|
||||||
ItemStack fromPlayer = stack.copy();
|
if (removedFromStorage.getCount() > 0) {
|
||||||
fromPlayer.setCount(stack.getCount() - removedFromStorage.getCount());
|
|
||||||
if (fromPlayer.getCount() > 0) {
|
|
||||||
Inventory playerInventory = player.getInventory();
|
Inventory playerInventory = player.getInventory();
|
||||||
for (int i = 0; i < playerInventory.size(); i++) {
|
for (int i = 0; i < playerInventory.size(); i++) {
|
||||||
if (ItemStack.areItemsEqual(playerInventory.getStack(i), fromPlayer)) {
|
if (ItemStack.areItemsEqual(playerInventory.getStack(i), removedFromStorage)) {
|
||||||
playerInventory.removeStack(i, fromPlayer.getCount());
|
playerInventory.removeStack(i, removedFromStorage.getCount());
|
||||||
break; // Only remove one stack per crafting iteration
|
break; // Only remove one stack per crafting iteration
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user