Craft if needed on interface
This commit is contained in:
		@@ -6,7 +6,6 @@ WIP
 | 
				
			|||||||
**TODO**
 | 
					**TODO**
 | 
				
			||||||
- Saving crafting task state
 | 
					- Saving crafting task state
 | 
				
			||||||
- Cancelling crafting tasks
 | 
					- Cancelling crafting tasks
 | 
				
			||||||
- "Craft if needed" upgrade on interface
 | 
					 | 
				
			||||||
- Textures
 | 
					- Textures
 | 
				
			||||||
- Update wiki
 | 
					- Update wiki
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -32,7 +32,7 @@ public class ContainerInterface extends ContainerBase {
 | 
				
			|||||||
            addSlotToContainer(new SlotFiltered(tile.getUpgradesInventory(), i, 187, 6 + (i * 18), new IItemValidator() {
 | 
					            addSlotToContainer(new SlotFiltered(tile.getUpgradesInventory(), i, 187, 6 + (i * 18), new IItemValidator() {
 | 
				
			||||||
                @Override
 | 
					                @Override
 | 
				
			||||||
                public boolean isValid(ItemStack stack) {
 | 
					                public boolean isValid(ItemStack stack) {
 | 
				
			||||||
                    return stack.getItem() == RefinedStorageItems.UPGRADE && stack.getMetadata() == ItemUpgrade.TYPE_SPEED;
 | 
					                    return stack.getItem() == RefinedStorageItems.UPGRADE && (stack.getMetadata() == ItemUpgrade.TYPE_SPEED || stack.getMetadata() == ItemUpgrade.TYPE_CRAFTING);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }));
 | 
					            }));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -90,6 +90,7 @@ public class ClientProxy extends CommonProxy {
 | 
				
			|||||||
        ModelLoader.setCustomModelResourceLocation(RefinedStorageItems.UPGRADE, 0, new ModelResourceLocation("refinedstorage:upgrade", "inventory"));
 | 
					        ModelLoader.setCustomModelResourceLocation(RefinedStorageItems.UPGRADE, 0, new ModelResourceLocation("refinedstorage:upgrade", "inventory"));
 | 
				
			||||||
        ModelLoader.setCustomModelResourceLocation(RefinedStorageItems.UPGRADE, ItemUpgrade.TYPE_RANGE, new ModelResourceLocation("refinedstorage:range_upgrade", "inventory"));
 | 
					        ModelLoader.setCustomModelResourceLocation(RefinedStorageItems.UPGRADE, ItemUpgrade.TYPE_RANGE, new ModelResourceLocation("refinedstorage:range_upgrade", "inventory"));
 | 
				
			||||||
        ModelLoader.setCustomModelResourceLocation(RefinedStorageItems.UPGRADE, ItemUpgrade.TYPE_SPEED, new ModelResourceLocation("refinedstorage:speed_upgrade", "inventory"));
 | 
					        ModelLoader.setCustomModelResourceLocation(RefinedStorageItems.UPGRADE, ItemUpgrade.TYPE_SPEED, new ModelResourceLocation("refinedstorage:speed_upgrade", "inventory"));
 | 
				
			||||||
 | 
					        ModelLoader.setCustomModelResourceLocation(RefinedStorageItems.UPGRADE, ItemUpgrade.TYPE_CRAFTING, new ModelResourceLocation("refinedstorage:crafting_upgrade", "inventory"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Blocks
 | 
					        // Blocks
 | 
				
			||||||
        ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RefinedStorageBlocks.CABLE), 0, new ModelResourceLocation("refinedstorage:cable", "inventory"));
 | 
					        ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RefinedStorageBlocks.CABLE), 0, new ModelResourceLocation("refinedstorage:cable", "inventory"));
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -80,6 +80,7 @@ public class CommonProxy {
 | 
				
			|||||||
        registerBlock(RefinedStorageBlocks.GRID);
 | 
					        registerBlock(RefinedStorageBlocks.GRID);
 | 
				
			||||||
        registerBlock(RefinedStorageBlocks.CRAFTING_MONITOR);
 | 
					        registerBlock(RefinedStorageBlocks.CRAFTING_MONITOR);
 | 
				
			||||||
        registerBlock(RefinedStorageBlocks.CRAFTER);
 | 
					        registerBlock(RefinedStorageBlocks.CRAFTER);
 | 
				
			||||||
 | 
					        registerBlock(RefinedStorageBlocks.PROCESSING_PATTERN_ENCODER);
 | 
				
			||||||
        registerBlock(RefinedStorageBlocks.DISK_DRIVE);
 | 
					        registerBlock(RefinedStorageBlocks.DISK_DRIVE);
 | 
				
			||||||
        registerBlock(RefinedStorageBlocks.STORAGE);
 | 
					        registerBlock(RefinedStorageBlocks.STORAGE);
 | 
				
			||||||
        registerBlock(RefinedStorageBlocks.EXTERNAL_STORAGE);
 | 
					        registerBlock(RefinedStorageBlocks.EXTERNAL_STORAGE);
 | 
				
			||||||
@@ -94,7 +95,6 @@ public class CommonProxy {
 | 
				
			|||||||
        registerBlock(RefinedStorageBlocks.WIRELESS_TRANSMITTER);
 | 
					        registerBlock(RefinedStorageBlocks.WIRELESS_TRANSMITTER);
 | 
				
			||||||
        registerBlock(RefinedStorageBlocks.MACHINE_CASING);
 | 
					        registerBlock(RefinedStorageBlocks.MACHINE_CASING);
 | 
				
			||||||
        registerBlock(RefinedStorageBlocks.CABLE);
 | 
					        registerBlock(RefinedStorageBlocks.CABLE);
 | 
				
			||||||
        registerBlock(RefinedStorageBlocks.PROCESSING_PATTERN_ENCODER);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        registerItem(RefinedStorageItems.QUARTZ_ENRICHED_IRON);
 | 
					        registerItem(RefinedStorageItems.QUARTZ_ENRICHED_IRON);
 | 
				
			||||||
        registerItem(RefinedStorageItems.STORAGE_DISK);
 | 
					        registerItem(RefinedStorageItems.STORAGE_DISK);
 | 
				
			||||||
@@ -417,6 +417,7 @@ public class CommonProxy {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        SoldererRegistry.addRecipe(new SoldererRecipeUpgrade(ItemUpgrade.TYPE_RANGE));
 | 
					        SoldererRegistry.addRecipe(new SoldererRecipeUpgrade(ItemUpgrade.TYPE_RANGE));
 | 
				
			||||||
        SoldererRegistry.addRecipe(new SoldererRecipeUpgrade(ItemUpgrade.TYPE_SPEED));
 | 
					        SoldererRegistry.addRecipe(new SoldererRecipeUpgrade(ItemUpgrade.TYPE_SPEED));
 | 
				
			||||||
 | 
					        SoldererRegistry.addRecipe(new SoldererRecipeUpgrade(ItemUpgrade.TYPE_CRAFTING));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Storage Blocks
 | 
					        // Storage Blocks
 | 
				
			||||||
        SoldererRegistry.addRecipe(new SoldererRecipeStorage(EnumStorageType.TYPE_1K, ItemStoragePart.TYPE_1K));
 | 
					        SoldererRegistry.addRecipe(new SoldererRecipeStorage(EnumStorageType.TYPE_1K, ItemStoragePart.TYPE_1K));
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -260,14 +260,20 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor
 | 
				
			|||||||
        craftingTasksToAdd.add(task);
 | 
					        craftingTasksToAdd.add(task);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public boolean hasCraftingTaskWithPattern(CraftingPattern pattern, int flags) {
 | 
					    public int getAmountOfCraftingTasksWithPattern(CraftingPattern pattern, int flags) {
 | 
				
			||||||
 | 
					        int amount = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (int i = 0; i < craftingTasks.size(); ++i) {
 | 
					        for (int i = 0; i < craftingTasks.size(); ++i) {
 | 
				
			||||||
            if (craftingTasks.get(i).getPattern().comparePattern(pattern, flags)) {
 | 
					            if (craftingTasks.get(i).getPattern().comparePattern(pattern, flags)) {
 | 
				
			||||||
                return true;
 | 
					                amount++;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return false;
 | 
					        return amount;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public boolean hasCraftingTaskWithPattern(CraftingPattern pattern, int flags) {
 | 
				
			||||||
 | 
					        return getAmountOfCraftingTasksWithPattern(pattern, flags) > 0;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void addCraftingTaskForPattern(CraftingPattern pattern) {
 | 
					    public void addCraftingTaskForPattern(CraftingPattern pattern) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -12,6 +12,7 @@ import net.minecraft.util.text.ITextComponent;
 | 
				
			|||||||
import refinedstorage.container.ContainerInterface;
 | 
					import refinedstorage.container.ContainerInterface;
 | 
				
			||||||
import refinedstorage.inventory.InventorySimple;
 | 
					import refinedstorage.inventory.InventorySimple;
 | 
				
			||||||
import refinedstorage.item.ItemUpgrade;
 | 
					import refinedstorage.item.ItemUpgrade;
 | 
				
			||||||
 | 
					import refinedstorage.tile.autocrafting.CraftingPattern;
 | 
				
			||||||
import refinedstorage.tile.config.ICompareConfig;
 | 
					import refinedstorage.tile.config.ICompareConfig;
 | 
				
			||||||
import refinedstorage.util.InventoryUtils;
 | 
					import refinedstorage.util.InventoryUtils;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -117,6 +118,18 @@ public class TileInterface extends TileMachine implements ICompareConfig, ISided
 | 
				
			|||||||
                                got.stackSize += took.stackSize;
 | 
					                                got.stackSize += took.stackSize;
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        if (hasCrafting(upgradesInventory)) {
 | 
				
			||||||
 | 
					                            CraftingPattern pattern = controller.getPatternForItem(wanted, compare);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            if (pattern != null && took == null || took.stackSize != needed) {
 | 
				
			||||||
 | 
					                                int tasksToCreate = needed - controller.getAmountOfCraftingTasksWithPattern(pattern, compare);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                                for (int j = 0; j < tasksToCreate; ++j) {
 | 
				
			||||||
 | 
					                                    controller.addCraftingTaskForPattern(pattern);
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            } else if (got != null) {
 | 
					            } else if (got != null) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -32,6 +32,8 @@ public class SoldererRecipeUpgrade implements ISoldererRecipe {
 | 
				
			|||||||
                return new ItemStack(Items.ender_pearl);
 | 
					                return new ItemStack(Items.ender_pearl);
 | 
				
			||||||
            case ItemUpgrade.TYPE_SPEED:
 | 
					            case ItemUpgrade.TYPE_SPEED:
 | 
				
			||||||
                return new ItemStack(Blocks.redstone_block);
 | 
					                return new ItemStack(Blocks.redstone_block);
 | 
				
			||||||
 | 
					            case ItemUpgrade.TYPE_CRAFTING:
 | 
				
			||||||
 | 
					                return new ItemStack(Blocks.crafting_table);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return null;
 | 
					        return null;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -0,0 +1,6 @@
 | 
				
			|||||||
 | 
					{
 | 
				
			||||||
 | 
					  "parent": "item/generated",
 | 
				
			||||||
 | 
					  "textures": {
 | 
				
			||||||
 | 
					    "layer0": "refinedstorage:items/crafting_upgrade"
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										
											BIN
										
									
								
								src/main/resources/assets/refinedstorage/textures/items/crafting_upgrade.png
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								src/main/resources/assets/refinedstorage/textures/items/crafting_upgrade.png
									
									
									
									
									
										Executable file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 217 B  | 
		Reference in New Issue
	
	Block a user