forked from BRNSystems/Server_storage
		
	Fix a glitch
This commit is contained in:
		@@ -11,7 +11,7 @@ loader_version=0.15.11
 | 
			
		||||
fabric_version=0.100.4+1.21
 | 
			
		||||
 | 
			
		||||
# Mod Properties
 | 
			
		||||
mod_version=3.0.2
 | 
			
		||||
mod_version=3.0.3
 | 
			
		||||
maven_group=systems.brn
 | 
			
		||||
archives_base_name=Server_storage
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -28,10 +28,7 @@ public class HardDrive {
 | 
			
		||||
    public Map<ItemStack, Integer> items;
 | 
			
		||||
 | 
			
		||||
    public void loadComponents() {
 | 
			
		||||
        Map<ItemStack, Integer> loadedItems = driveStack.getComponents().getOrDefault(ITEMSTACK_MAP, new HashMap<>());
 | 
			
		||||
        if (this.items == null) {
 | 
			
		||||
            this.items = loadedItems;
 | 
			
		||||
        }
 | 
			
		||||
        this.items = driveStack.getComponents().getOrDefault(ITEMSTACK_MAP, new HashMap<>());
 | 
			
		||||
        updateData();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -123,20 +120,19 @@ public class HardDrive {
 | 
			
		||||
        blockEntity.markDirty();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public ItemStack removeStackFromInventory(ItemStack stack) {
 | 
			
		||||
        int outCount = 0;
 | 
			
		||||
    public ItemStack removeStackFromInventoryRemains(ItemStack stack) {
 | 
			
		||||
        int outCount = stack.getCount();
 | 
			
		||||
        ItemStack outStack = stack.copy();
 | 
			
		||||
        for (Map.Entry<ItemStack, Integer> entry : items.entrySet()) {
 | 
			
		||||
            if (canCombine(entry.getKey(), stack)) {
 | 
			
		||||
                int countInDrive = entry.getValue();
 | 
			
		||||
                int needToRemove = stack.getCount();
 | 
			
		||||
 | 
			
		||||
                if (countInDrive <= needToRemove) {
 | 
			
		||||
                if (countInDrive <= outCount) {
 | 
			
		||||
                    items.remove(entry.getKey());
 | 
			
		||||
                    needToRemove -= countInDrive;
 | 
			
		||||
                    outCount += needToRemove;
 | 
			
		||||
                    outCount -= countInDrive;
 | 
			
		||||
                } else {
 | 
			
		||||
                    entry.setValue(countInDrive - needToRemove);
 | 
			
		||||
                    entry.setValue(countInDrive - outCount);
 | 
			
		||||
                    outCount -= countInDrive;
 | 
			
		||||
                }
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
@@ -187,8 +187,8 @@ public class StorageNetwork {
 | 
			
		||||
        ItemStack outStack = stackToRemove.copy();
 | 
			
		||||
 | 
			
		||||
        for (HardDrive drive : drives) {
 | 
			
		||||
            outStack = drive.removeStackFromInventory(outStack);
 | 
			
		||||
            if (outStack.getCount() >= stackToRemove.getCount()) {
 | 
			
		||||
            ItemStack removedStack = drive.removeStackFromInventoryRemains(outStack);
 | 
			
		||||
            if (removedStack.getCount() <= 0) {
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -92,6 +92,7 @@ public class CraftingScreen extends PagedGui {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private boolean canCraft(RecipeEntry<CraftingRecipe> recipeEntry) {
 | 
			
		||||
        blockEntity.reindexDrives();
 | 
			
		||||
        for (Ingredient ingredient : recipeEntry.value().getIngredients()) {
 | 
			
		||||
            if (findMatchingStack(ingredient) == null) {
 | 
			
		||||
                return false;
 | 
			
		||||
@@ -119,7 +120,6 @@ public class CraftingScreen extends PagedGui {
 | 
			
		||||
 | 
			
		||||
        // Add crafted item to the appropriate inventory
 | 
			
		||||
        ItemStack outputStack = recipeEntry.value().getResult(storageScreen.getPlayer().getRegistryManager()).copy();
 | 
			
		||||
        int maxStackSize = outputStack.getMaxCount();
 | 
			
		||||
 | 
			
		||||
        if (toPlayerInventory) {
 | 
			
		||||
            PlayerInventory playerInventory = player.getInventory();
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user