forked from BRNSystems/Server_storage
		
	Fix crafting
This commit is contained in:
		@@ -4,14 +4,14 @@ org.gradle.jvmargs=-Xmx1G
 | 
			
		||||
# check these on https://modmuss50.me/fabric.html
 | 
			
		||||
 | 
			
		||||
minecraft_version=1.21
 | 
			
		||||
yarn_mappings=1.21+build.8
 | 
			
		||||
loader_version=0.15.11
 | 
			
		||||
yarn_mappings=1.21+build.9
 | 
			
		||||
loader_version=0.16.0
 | 
			
		||||
 | 
			
		||||
# Fabric API
 | 
			
		||||
fabric_version=0.100.6+1.21
 | 
			
		||||
 | 
			
		||||
# Mod Properties
 | 
			
		||||
mod_version=3.1.0
 | 
			
		||||
mod_version=3.1.1
 | 
			
		||||
maven_group=systems.brn
 | 
			
		||||
archives_base_name=Serverstorage
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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