diff --git a/changelog b/changelog index b5b39f0d4..0e1a5cf5a 100644 --- a/changelog +++ b/changelog @@ -29,6 +29,18 @@ * Increased the blast furnace's fuel buffer by 50%, allowing coke blocks to be used * If an RoR controller tries to parse an integer, but the supplied string represents a decimal, instead of canceling the operation, the system will now interpret decimals and round them to be integers * This means that the AUTOCAL can now send RoR commands using calculated values directly without the use of `round` or `evalr` +* Assembly machines now support Redstone-over-Radio + * Active state (0 or 1), progress (0-100) and current recipe (internal name) can now be read + * The recipe can be set using a controller + * Do note that setting a recipe that needs a blueprint without that blueprint will not work + * RoR set recipes cause the assembler to go into low power mode, making it run at only 25% speed (visible through the blue progress bar) + * The speed penalty is removed as soon as a recipe is assigned manually again +* The AUTOCAL's script interpreter now runs MS-ES v1.1 (First Extended Instruction Set) + * Allows the use of a global stack, similar to the buffer which can hold 256 values + * Allows splitting of strings and counting of string fragments + * Adds substring operations + * Polling for receiving only fresh RoR signals + * A command for writing the world time to the buffer, allowing for more precise timers ## Fixed * Fixed AUTOCAL's number comparison functions not working with variable substitution as advertised diff --git a/src/main/java/api/hbm/ntl/StackCache.java b/src/main/java/api/hbm/ntl/StackCache.java index 004ead61a..7d941d73c 100644 --- a/src/main/java/api/hbm/ntl/StackCache.java +++ b/src/main/java/api/hbm/ntl/StackCache.java @@ -197,7 +197,11 @@ public class StackCache { public static long getStackIdentity(Item item, int meta, NBTTagCompound nbt) { if(item == null) return getNullIdentity(); - long identity = Item.getIdFromItem(item) * 27644437; + return getStackIdentity(Item.getIdFromItem(item), meta, nbt); + } + + public static long getStackIdentity(int item, int meta, NBTTagCompound nbt) { + long identity = item * 27644437; identity += meta; identity *= 27644437; if(nbt != null) identity += nbt.hashCode(); diff --git a/src/main/java/com/hbm/inventory/SlotPattern.java b/src/main/java/com/hbm/inventory/SlotPattern.java index a1bdc6c67..317424214 100644 --- a/src/main/java/com/hbm/inventory/SlotPattern.java +++ b/src/main/java/com/hbm/inventory/SlotPattern.java @@ -16,10 +16,10 @@ public class SlotPattern extends Slot { public SlotPattern(IInventory inv, int index, int x, int y) { super(inv, index, x, y); } - - public SlotPattern(IInventory inv, int index, int x, int y, boolean allowStackSize) { - super(inv, index, x, y); - this.allowStackSize = allowStackSize; + + public SlotPattern allowStackSize() { + this.allowStackSize = true; + return this; } @Override diff --git a/src/main/java/com/hbm/inventory/container/ContainerAutocrafter.java b/src/main/java/com/hbm/inventory/container/ContainerAutocrafter.java index 2c8b0438b..8dc57f397 100644 --- a/src/main/java/com/hbm/inventory/container/ContainerAutocrafter.java +++ b/src/main/java/com/hbm/inventory/container/ContainerAutocrafter.java @@ -24,7 +24,7 @@ public class ContainerAutocrafter extends ContainerBase { this.addSlotToContainer(new SlotPattern(tedf, j + i * 3, 44 + j * 18, 22 + i * 18)); } } - this.addSlotToContainer(new SlotPattern(tedf, 9, 116, 40, true)); + this.addSlotToContainer(new SlotPattern(tedf, 9, 116, 40).allowStackSize()); /* RECIPE */ addSlots(tedf,10, 44, 86, 3, 3); diff --git a/src/main/java/com/hbm/inventory/container/ContainerPneumoStorageExporter.java b/src/main/java/com/hbm/inventory/container/ContainerPneumoStorageExporter.java index 95776aa6d..4928ba349 100644 --- a/src/main/java/com/hbm/inventory/container/ContainerPneumoStorageExporter.java +++ b/src/main/java/com/hbm/inventory/container/ContainerPneumoStorageExporter.java @@ -14,7 +14,7 @@ public class ContainerPneumoStorageExporter extends ContainerBase { super(invPlayer, exporter); for(int i = 0; i < 9; i++) { - this.addSlotToContainer(new SlotPattern(exporter, i, 17 + (i % 3) * 18, 17 + (i / 3) * 18, true)); + this.addSlotToContainer(new SlotPattern(exporter, i, 17 + (i % 3) * 18, 17 + (i / 3) * 18).allowStackSize()); } addSlots(exporter, 9, 80, 17, 3, 3); diff --git a/src/main/java/com/hbm/inventory/gui/GUIFusionTorus.java b/src/main/java/com/hbm/inventory/gui/GUIFusionTorus.java index 98e11de61..9e7160305 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIFusionTorus.java +++ b/src/main/java/com/hbm/inventory/gui/GUIFusionTorus.java @@ -41,7 +41,7 @@ public class GUIFusionTorus extends GuiInfoContainer { torus.coolantTanks[0].renderTankInfo(this, mouseX, mouseY, guiLeft + 188, guiTop + 46, 16, 52); torus.coolantTanks[1].renderTankInfo(this, mouseX, mouseY, guiLeft + 206, guiTop + 46, 16, 52); - FusionRecipe recipe = (FusionRecipe) FusionRecipes.INSTANCE.recipeNameMap.get(this.torus.fusionModule.recipe); + FusionRecipe recipe = (FusionRecipe) this.torus.fusionModule.getRecipe(); if(recipe != null) { drawCustomInfoStat(mouseX, mouseY, guiLeft + 43, guiTop + 115, 18, 18, mouseX, mouseY, EnumChatFormatting.GREEN + "-> " + EnumChatFormatting.RESET + BobMathUtil.getShortNumber(torus.klystronEnergy) + "KyU / " + BobMathUtil.getShortNumber(recipe.ignitionTemp) + "KyU"); @@ -70,7 +70,7 @@ public class GUIFusionTorus extends GuiInfoContainer { protected void mouseClicked(int x, int y, int button) { super.mouseClicked(x, y, button); - if(this.checkClick(x, y, 43, 80, 18, 18)) GUIScreenRecipeSelector.openSelector(FusionRecipes.INSTANCE, torus, torus.fusionModule.recipe, 0, ItemBlueprints.grabPool(torus.slots[1]), this); + if(this.checkClick(x, y, 43, 80, 18, 18)) GUIScreenRecipeSelector.openSelector(FusionRecipes.INSTANCE, torus, torus.fusionModule.getRecipeName(), 0, ItemBlueprints.grabPool(torus.slots[1]), this); } @Override @@ -103,7 +103,7 @@ public class GUIFusionTorus extends GuiInfoContainer { drawTexturedModalRect(guiLeft + 98, guiTop + 91, 0, 250, j, 6); } - FusionRecipe recipe = FusionRecipes.INSTANCE.recipeNameMap.get(torus.fusionModule.recipe); + FusionRecipe recipe = (FusionRecipe) torus.fusionModule.getRecipe(); // power LED if(recipe != null && torus.power >= recipe.power) drawTexturedModalRect(guiLeft + 160, guiTop + 115, 246, 14, 8, 8); diff --git a/src/main/java/com/hbm/inventory/gui/GUIMachineAssemblyFactory.java b/src/main/java/com/hbm/inventory/gui/GUIMachineAssemblyFactory.java index 11f7db844..d08490d19 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIMachineAssemblyFactory.java +++ b/src/main/java/com/hbm/inventory/gui/GUIMachineAssemblyFactory.java @@ -47,8 +47,8 @@ public class GUIMachineAssemblyFactory extends GuiInfoContainer { this.drawElectricityInfo(this, mouseX, mouseY, guiLeft + 234, guiTop + 18, 16, 92, assembler.power, assembler.maxPower); for(int i = 0; i < 4; i++) if(guiLeft + 6 + (i % 2) * 109 <= mouseX && guiLeft + 6 + (i % 2) * 109 + 18 > mouseX && guiTop + 53 + (i / 2) * 56 < mouseY && guiTop + 53 + (i / 2) * 56 + 18 >= mouseY) { - if(this.assembler.assemblerModule[i].recipe != null && AssemblyMachineRecipes.INSTANCE.recipeNameMap.containsKey(this.assembler.assemblerModule[i].recipe)) { - GenericRecipe recipe = (GenericRecipe) AssemblyMachineRecipes.INSTANCE.recipeNameMap.get(this.assembler.assemblerModule[i].recipe); + if(this.assembler.assemblerModule[i].getRecipeName() != null && AssemblyMachineRecipes.INSTANCE.recipeNameMap.containsKey(this.assembler.assemblerModule[i].getRecipeName())) { + GenericRecipe recipe = this.assembler.assemblerModule[i].getRecipe(); GUIElements.drawHoveringTextRecipe(recipe.print(), mouseX, mouseY, this.fontRendererObj, itemRender, this.width, this.height); } else { this.drawCreativeTabHoveringText(EnumChatFormatting.YELLOW + I18nUtil.resolveKey("gui.recipe.setRecipe"), mouseX, mouseY); @@ -60,7 +60,7 @@ public class GUIMachineAssemblyFactory extends GuiInfoContainer { protected void mouseClicked(int x, int y, int button) { super.mouseClicked(x, y, button); - for(int i = 0; i < 4; i++) if(this.checkClick(x, y, 6 + (i % 2) * 109, 53 + (i / 2) * 56, 18, 18)) GUIScreenRecipeSelector.openSelector(AssemblyMachineRecipes.INSTANCE, assembler, assembler.assemblerModule[i].recipe, i, ItemBlueprints.grabPool(assembler.slots[4 + i * 14]), this); + for(int i = 0; i < 4; i++) if(this.checkClick(x, y, 6 + (i % 2) * 109, 53 + (i / 2) * 56, 18, 18)) GUIScreenRecipeSelector.openSelector(AssemblyMachineRecipes.INSTANCE, assembler, assembler.assemblerModule[i].getRecipeName(), i, ItemBlueprints.grabPool(assembler.slots[4 + i * 14]), this); } @Override @@ -87,7 +87,7 @@ public class GUIMachineAssemblyFactory extends GuiInfoContainer { } for(int g = 0; g < 4; g++) { - GenericRecipe recipe = AssemblyMachineRecipes.INSTANCE.recipeNameMap.get(assembler.assemblerModule[g].recipe); + GenericRecipe recipe = assembler.assemblerModule[g].getRecipe(); /// LEFT LED if(assembler.didProcess[g]) { @@ -105,7 +105,7 @@ public class GUIMachineAssemblyFactory extends GuiInfoContainer { } for(int g = 0; g < 4; g++) { - GenericRecipe recipe = AssemblyMachineRecipes.INSTANCE.recipeNameMap.get(assembler.assemblerModule[g].recipe); + GenericRecipe recipe = assembler.assemblerModule[g].getRecipe(); this.renderItem(recipe != null ? recipe.getIcon() : TEMPLATE_FOLDER, 7 + (g % 2) * 109, 54 + (g / 2) * 56); diff --git a/src/main/java/com/hbm/inventory/gui/GUIMachineAssemblyMachine.java b/src/main/java/com/hbm/inventory/gui/GUIMachineAssemblyMachine.java index 0e5f8184c..bcb51491b 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIMachineAssemblyMachine.java +++ b/src/main/java/com/hbm/inventory/gui/GUIMachineAssemblyMachine.java @@ -42,8 +42,8 @@ public class GUIMachineAssemblyMachine extends GuiInfoContainer { this.drawElectricityInfo(this, mouseX, mouseY, guiLeft + 152, guiTop + 18, 16, 61, assembler.power, assembler.maxPower); if(guiLeft + 7 <= mouseX && guiLeft + 7 + 18 > mouseX && guiTop + 125 < mouseY && guiTop + 125 + 18 >= mouseY) { - if(this.assembler.assemblerModule.recipe != null && AssemblyMachineRecipes.INSTANCE.recipeNameMap.containsKey(this.assembler.assemblerModule.recipe)) { - GenericRecipe recipe = (GenericRecipe) AssemblyMachineRecipes.INSTANCE.recipeNameMap.get(this.assembler.assemblerModule.recipe); + if(this.assembler.assemblerModule.getRecipeName() != null && AssemblyMachineRecipes.INSTANCE.recipeNameMap.containsKey(this.assembler.assemblerModule.getRecipeName())) { + GenericRecipe recipe = this.assembler.assemblerModule.getRecipe(); GUIElements.drawHoveringTextRecipe(recipe.print(), mouseX, mouseY, this.fontRendererObj, itemRender, this.width, this.height); } else { this.drawCreativeTabHoveringText(EnumChatFormatting.YELLOW + I18nUtil.resolveKey("gui.recipe.setRecipe"), mouseX, mouseY); @@ -55,7 +55,7 @@ public class GUIMachineAssemblyMachine extends GuiInfoContainer { protected void mouseClicked(int x, int y, int button) { super.mouseClicked(x, y, button); - if(this.checkClick(x, y, 7, 125, 18, 18)) GUIScreenRecipeSelector.openSelector(AssemblyMachineRecipes.INSTANCE, assembler, assembler.assemblerModule.recipe, 0, ItemBlueprints.grabPool(assembler.slots[1]), this); + if(this.checkClick(x, y, 7, 125, 18, 18)) GUIScreenRecipeSelector.openSelector(AssemblyMachineRecipes.INSTANCE, assembler, assembler.assemblerModule.getRecipeName(), 0, ItemBlueprints.grabPool(assembler.slots[1]), this); } @Override @@ -77,10 +77,10 @@ public class GUIMachineAssemblyMachine extends GuiInfoContainer { if(assembler.assemblerModule.progress > 0) { int j = (int) Math.ceil(70 * assembler.assemblerModule.progress); - drawTexturedModalRect(guiLeft + 62, guiTop + 126, 176, 61, j, 16); + drawTexturedModalRect(guiLeft + 62, guiTop + 126, 176, 61 + (assembler.assemblerModule.restrictedMode ? 16 : 0), j, 16); } - GenericRecipe recipe = AssemblyMachineRecipes.INSTANCE.recipeNameMap.get(assembler.assemblerModule.recipe); + GenericRecipe recipe = assembler.assemblerModule.getRecipe(); /// LEFT LED if(assembler.didProcess) { diff --git a/src/main/java/com/hbm/inventory/gui/GUIMachineChemicalFactory.java b/src/main/java/com/hbm/inventory/gui/GUIMachineChemicalFactory.java index 885411e82..e20b94d4f 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIMachineChemicalFactory.java +++ b/src/main/java/com/hbm/inventory/gui/GUIMachineChemicalFactory.java @@ -47,8 +47,8 @@ public class GUIMachineChemicalFactory extends GuiInfoContainer { this.drawElectricityInfo(this, mouseX, mouseY, guiLeft + 224, guiTop + 18, 16, 68, chemplant.power, chemplant.maxPower); for(int i = 0; i < 4; i++) if(guiLeft + 74 <= mouseX && guiLeft + 74 + 18 > mouseX && guiTop + 19 + i * 22 < mouseY && guiTop + 19 + i * 22 + 18 >= mouseY) { - if(this.chemplant.chemplantModule[i].recipe != null && ChemicalPlantRecipes.INSTANCE.recipeNameMap.containsKey(this.chemplant.chemplantModule[i].recipe)) { - GenericRecipe recipe = (GenericRecipe) ChemicalPlantRecipes.INSTANCE.recipeNameMap.get(this.chemplant.chemplantModule[i].recipe); + if(this.chemplant.chemplantModule[i].getRecipeName() != null && ChemicalPlantRecipes.INSTANCE.recipeNameMap.containsKey(this.chemplant.chemplantModule[i].getRecipeName())) { + GenericRecipe recipe = this.chemplant.chemplantModule[i].getRecipe(); GUIElements.drawHoveringTextRecipe(recipe.print(), mouseX, mouseY, this.fontRendererObj, itemRender, this.width, this.height); } else { this.drawCreativeTabHoveringText(EnumChatFormatting.YELLOW + I18nUtil.resolveKey("gui.recipe.setRecipe"), mouseX, mouseY); @@ -60,7 +60,7 @@ public class GUIMachineChemicalFactory extends GuiInfoContainer { protected void mouseClicked(int x, int y, int button) { super.mouseClicked(x, y, button); - for(int i = 0; i < 4; i++) if(this.checkClick(x, y, 74, 19 + i * 22, 18, 18)) GUIScreenRecipeSelector.openSelector(ChemicalPlantRecipes.INSTANCE, chemplant, chemplant.chemplantModule[i].recipe, i, ItemBlueprints.grabPool(chemplant.slots[4 + i * 7]), this); + for(int i = 0; i < 4; i++) if(this.checkClick(x, y, 74, 19 + i * 22, 18, 18)) GUIScreenRecipeSelector.openSelector(ChemicalPlantRecipes.INSTANCE, chemplant, chemplant.chemplantModule[i].getRecipeName(), i, ItemBlueprints.grabPool(chemplant.slots[4 + i * 7]), this); } @Override @@ -87,7 +87,7 @@ public class GUIMachineChemicalFactory extends GuiInfoContainer { } for(int g = 0; g < 4; g++) { - GenericRecipe recipe = ChemicalPlantRecipes.INSTANCE.recipeNameMap.get(chemplant.chemplantModule[g].recipe); + GenericRecipe recipe = chemplant.chemplantModule[g].getRecipe(); /// LEFT LED if(chemplant.didProcess[g]) { @@ -105,7 +105,7 @@ public class GUIMachineChemicalFactory extends GuiInfoContainer { } for(int g = 0; g < 4; g++) { // not a great way of doing it but at least we eliminate state leak bullshit - GenericRecipe recipe = ChemicalPlantRecipes.INSTANCE.recipeNameMap.get(chemplant.chemplantModule[g].recipe); + GenericRecipe recipe = chemplant.chemplantModule[g].getRecipe(); this.renderItem(recipe != null ? recipe.getIcon() : TEMPLATE_FOLDER, 75, 20 + g * 22); diff --git a/src/main/java/com/hbm/inventory/gui/GUIMachineChemicalPlant.java b/src/main/java/com/hbm/inventory/gui/GUIMachineChemicalPlant.java index bc63a81b5..0f42776f1 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIMachineChemicalPlant.java +++ b/src/main/java/com/hbm/inventory/gui/GUIMachineChemicalPlant.java @@ -43,8 +43,8 @@ public class GUIMachineChemicalPlant extends GuiInfoContainer { this.drawElectricityInfo(this, mouseX, mouseY, guiLeft + 152, guiTop + 18, 16, 61, chemplant.power, chemplant.maxPower); if(guiLeft + 7 <= mouseX && guiLeft + 7 + 18 > mouseX && guiTop + 125 < mouseY && guiTop + 125 + 18 >= mouseY) { - if(this.chemplant.chemplantModule.recipe != null && ChemicalPlantRecipes.INSTANCE.recipeNameMap.containsKey(this.chemplant.chemplantModule.recipe)) { - GenericRecipe recipe = (GenericRecipe) ChemicalPlantRecipes.INSTANCE.recipeNameMap.get(this.chemplant.chemplantModule.recipe); + if(this.chemplant.chemplantModule.getRecipe() != null && ChemicalPlantRecipes.INSTANCE.recipeNameMap.containsKey(this.chemplant.chemplantModule.getRecipeName())) { + GenericRecipe recipe = this.chemplant.chemplantModule.getRecipe(); GUIElements.drawHoveringTextRecipe(recipe.print(), mouseX, mouseY, this.fontRendererObj, itemRender, this.width, this.height); } else { this.drawCreativeTabHoveringText(EnumChatFormatting.YELLOW + I18nUtil.resolveKey("gui.recipe.setRecipe"), mouseX, mouseY); @@ -56,7 +56,7 @@ public class GUIMachineChemicalPlant extends GuiInfoContainer { protected void mouseClicked(int x, int y, int button) { super.mouseClicked(x, y, button); - if(this.checkClick(x, y, 7, 125, 18, 18)) GUIScreenRecipeSelector.openSelector(ChemicalPlantRecipes.INSTANCE, chemplant, chemplant.chemplantModule.recipe, 0, ItemBlueprints.grabPool(chemplant.slots[1]), this); + if(this.checkClick(x, y, 7, 125, 18, 18)) GUIScreenRecipeSelector.openSelector(ChemicalPlantRecipes.INSTANCE, chemplant, chemplant.chemplantModule.getRecipeName(), 0, ItemBlueprints.grabPool(chemplant.slots[1]), this); } @Override @@ -81,7 +81,7 @@ public class GUIMachineChemicalPlant extends GuiInfoContainer { drawTexturedModalRect(guiLeft + 62, guiTop + 126, 176, 61, j, 16); } - GenericRecipe recipe = ChemicalPlantRecipes.INSTANCE.recipeNameMap.get(chemplant.chemplantModule.recipe); + GenericRecipe recipe = chemplant.chemplantModule.getRecipe(); /// LEFT LED if(chemplant.didProcess) { diff --git a/src/main/java/com/hbm/inventory/gui/GUIMachinePUREX.java b/src/main/java/com/hbm/inventory/gui/GUIMachinePUREX.java index 2ae922c50..b6f48cbeb 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIMachinePUREX.java +++ b/src/main/java/com/hbm/inventory/gui/GUIMachinePUREX.java @@ -44,8 +44,8 @@ public class GUIMachinePUREX extends GuiInfoContainer { this.drawElectricityInfo(this, mouseX, mouseY, guiLeft + 152, guiTop + 18, 16, 61, purex.power, purex.maxPower); if(guiLeft + 7 <= mouseX && guiLeft + 7 + 18 > mouseX && guiTop + 125 < mouseY && guiTop + 125 + 18 >= mouseY) { - if(this.purex.purexModule.recipe != null && PUREXRecipes.INSTANCE.recipeNameMap.containsKey(this.purex.purexModule.recipe)) { - GenericRecipe recipe = (GenericRecipe) PUREXRecipes.INSTANCE.recipeNameMap.get(this.purex.purexModule.recipe); + if(this.purex.purexModule.getRecipe() != null && PUREXRecipes.INSTANCE.recipeNameMap.containsKey(this.purex.purexModule.getRecipe())) { + GenericRecipe recipe = this.purex.purexModule.getRecipe(); GUIElements.drawHoveringTextRecipe(recipe.print(), mouseX, mouseY, this.fontRendererObj, itemRender, this.width, this.height); } else { this.drawCreativeTabHoveringText(EnumChatFormatting.YELLOW + I18nUtil.resolveKey("gui.recipe.setRecipe"), mouseX, mouseY); @@ -57,7 +57,7 @@ public class GUIMachinePUREX extends GuiInfoContainer { protected void mouseClicked(int x, int y, int button) { super.mouseClicked(x, y, button); - if(this.checkClick(x, y, 7, 125, 18, 18)) GUIScreenRecipeSelector.openSelector(PUREXRecipes.INSTANCE, purex, purex.purexModule.recipe, 0, ItemBlueprints.grabPool(purex.slots[1]), this); + if(this.checkClick(x, y, 7, 125, 18, 18)) GUIScreenRecipeSelector.openSelector(PUREXRecipes.INSTANCE, purex, purex.purexModule.getRecipeName(), 0, ItemBlueprints.grabPool(purex.slots[1]), this); } @Override @@ -82,7 +82,7 @@ public class GUIMachinePUREX extends GuiInfoContainer { drawTexturedModalRect(guiLeft + 62, guiTop + 126, 176, 61, j, 16); } - GenericRecipe recipe = PUREXRecipes.INSTANCE.recipeNameMap.get(purex.purexModule.recipe); + GenericRecipe recipe = purex.purexModule.getRecipe(); /// LEFT LED if(purex.didProcess) { diff --git a/src/main/java/com/hbm/inventory/gui/GUIMachinePlasmaForge.java b/src/main/java/com/hbm/inventory/gui/GUIMachinePlasmaForge.java index 2516072f7..98b9f663c 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIMachinePlasmaForge.java +++ b/src/main/java/com/hbm/inventory/gui/GUIMachinePlasmaForge.java @@ -47,15 +47,15 @@ public class GUIMachinePlasmaForge extends GuiInfoContainer { this.drawElectricityInfo(this, mouseX, mouseY, guiLeft + 152, guiTop + 18, 16, 62, forge.power, forge.maxPower); if(guiLeft + 7 <= mouseX && guiLeft + 7 + 18 > mouseX && guiTop + 80 < mouseY && guiTop + 80 + 18 >= mouseY) { - if(this.forge.plasmaModule.recipe != null && PlasmaForgeRecipes.INSTANCE.recipeNameMap.containsKey(this.forge.plasmaModule.recipe)) { - GenericRecipe recipe = (GenericRecipe) PlasmaForgeRecipes.INSTANCE.recipeNameMap.get(this.forge.plasmaModule.recipe); + if(this.forge.plasmaModule.getRecipeName() != null && PlasmaForgeRecipes.INSTANCE.recipeNameMap.containsKey(this.forge.plasmaModule.getRecipeName())) { + GenericRecipe recipe = this.forge.plasmaModule.getRecipe(); GUIElements.drawHoveringTextRecipe(recipe.print(), mouseX, mouseY, this.fontRendererObj, itemRender, this.width, this.height); } else { this.drawCreativeTabHoveringText(EnumChatFormatting.YELLOW + I18nUtil.resolveKey("gui.recipe.setRecipe"), mouseX, mouseY); } } - PlasmaForgeRecipe recipe = (PlasmaForgeRecipe) PlasmaForgeRecipes.INSTANCE.recipeNameMap.get(forge.plasmaModule.recipe); + PlasmaForgeRecipe recipe = (PlasmaForgeRecipe) forge.plasmaModule.getRecipe(); if(recipe != null) { drawCustomInfoStat(mouseX, mouseY, guiLeft + 25, guiTop + 115, 18, 18, mouseX, mouseY, EnumChatFormatting.GREEN + "-> " + EnumChatFormatting.RESET + BobMathUtil.getShortNumber(forge.plasmaEnergySync) + "TU / " + BobMathUtil.getShortNumber(recipe.ignitionTemp) + "TU"); @@ -102,7 +102,7 @@ public class GUIMachinePlasmaForge extends GuiInfoContainer { protected void mouseClicked(int x, int y, int button) { super.mouseClicked(x, y, button); - if(this.checkClick(x, y, 7, 80, 18, 18)) GUIScreenRecipeSelector.openSelector(PlasmaForgeRecipes.INSTANCE, forge, forge.plasmaModule.recipe, 0, ItemBlueprints.grabPool(forge.slots[1]), this); + if(this.checkClick(x, y, 7, 80, 18, 18)) GUIScreenRecipeSelector.openSelector(PlasmaForgeRecipes.INSTANCE, forge, forge.plasmaModule.getRecipeName(), 0, ItemBlueprints.grabPool(forge.slots[1]), this); } @Override @@ -127,7 +127,7 @@ public class GUIMachinePlasmaForge extends GuiInfoContainer { drawTexturedModalRect(guiLeft + 62, guiTop + 81, 176, 62, j, 16); } - PlasmaForgeRecipe recipe = (PlasmaForgeRecipe) PlasmaForgeRecipes.INSTANCE.recipeNameMap.get(forge.plasmaModule.recipe); + PlasmaForgeRecipe recipe = (PlasmaForgeRecipe) forge.plasmaModule.getRecipe(); /// LEFT LED if(forge.didProcess) { diff --git a/src/main/java/com/hbm/inventory/gui/GUIMachinePrecAss.java b/src/main/java/com/hbm/inventory/gui/GUIMachinePrecAss.java index 53d04d6f7..aa5a400cf 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIMachinePrecAss.java +++ b/src/main/java/com/hbm/inventory/gui/GUIMachinePrecAss.java @@ -42,8 +42,8 @@ public class GUIMachinePrecAss extends GuiInfoContainer { this.drawElectricityInfo(this, mouseX, mouseY, guiLeft + 152, guiTop + 18, 16, 61, assembler.power, assembler.maxPower); if(guiLeft + 7 <= mouseX && guiLeft + 7 + 18 > mouseX && guiTop + 125 < mouseY && guiTop + 125 + 18 >= mouseY) { - if(this.assembler.assemblerModule.recipe != null && PrecAssRecipes.INSTANCE.recipeNameMap.containsKey(this.assembler.assemblerModule.recipe)) { - GenericRecipe recipe = (GenericRecipe) PrecAssRecipes.INSTANCE.recipeNameMap.get(this.assembler.assemblerModule.recipe); + if(this.assembler.assemblerModule.getRecipeName() != null && PrecAssRecipes.INSTANCE.recipeNameMap.containsKey(this.assembler.assemblerModule.getRecipeName())) { + GenericRecipe recipe = this.assembler.assemblerModule.getRecipe(); GUIElements.drawHoveringTextRecipe(recipe.print(), mouseX, mouseY, this.fontRendererObj, itemRender, this.width, this.height); } else { this.drawCreativeTabHoveringText(EnumChatFormatting.YELLOW + I18nUtil.resolveKey("gui.recipe.setRecipe"), mouseX, mouseY); @@ -55,7 +55,7 @@ public class GUIMachinePrecAss extends GuiInfoContainer { protected void mouseClicked(int x, int y, int button) { super.mouseClicked(x, y, button); - if(this.checkClick(x, y, 7, 125, 18, 18)) GUIScreenRecipeSelector.openSelector(PrecAssRecipes.INSTANCE, assembler, assembler.assemblerModule.recipe, 0, ItemBlueprints.grabPool(assembler.slots[1]), this); + if(this.checkClick(x, y, 7, 125, 18, 18)) GUIScreenRecipeSelector.openSelector(PrecAssRecipes.INSTANCE, assembler, assembler.assemblerModule.getRecipeName(), 0, ItemBlueprints.grabPool(assembler.slots[1]), this); } @Override @@ -80,7 +80,7 @@ public class GUIMachinePrecAss extends GuiInfoContainer { drawTexturedModalRect(guiLeft + 62, guiTop + 126, 176, 61, j, 16); } - GenericRecipe recipe = PrecAssRecipes.INSTANCE.recipeNameMap.get(assembler.assemblerModule.recipe); + GenericRecipe recipe = assembler.assemblerModule.getRecipe(); /// LEFT LED if(assembler.didProcess) { diff --git a/src/main/java/com/hbm/inventory/recipes/CrucibleRecipe.java b/src/main/java/com/hbm/inventory/recipes/CrucibleRecipe.java index 65d4fa4b4..4c73a4289 100644 --- a/src/main/java/com/hbm/inventory/recipes/CrucibleRecipe.java +++ b/src/main/java/com/hbm/inventory/recipes/CrucibleRecipe.java @@ -41,8 +41,8 @@ public class CrucibleRecipe extends GenericRecipe { @Override public List print() { List list = new ArrayList(); - list.add(EnumChatFormatting.YELLOW + this.getLocalizedName()); + header(list); input(list); output(list); diff --git a/src/main/java/com/hbm/inventory/recipes/PlasmaForgeRecipe.java b/src/main/java/com/hbm/inventory/recipes/PlasmaForgeRecipe.java index 4637b8bd0..8183f941c 100644 --- a/src/main/java/com/hbm/inventory/recipes/PlasmaForgeRecipe.java +++ b/src/main/java/com/hbm/inventory/recipes/PlasmaForgeRecipe.java @@ -23,8 +23,8 @@ public class PlasmaForgeRecipe extends GenericRecipe { public List print() { List list = new ArrayList(); - list.add(EnumChatFormatting.YELLOW + this.getLocalizedName()); + header(list); autoSwitch(list); duration(list); power(list); diff --git a/src/main/java/com/hbm/inventory/recipes/loader/GenericRecipe.java b/src/main/java/com/hbm/inventory/recipes/loader/GenericRecipe.java index 40ee9bf27..4f8a49eb5 100644 --- a/src/main/java/com/hbm/inventory/recipes/loader/GenericRecipe.java +++ b/src/main/java/com/hbm/inventory/recipes/loader/GenericRecipe.java @@ -4,6 +4,8 @@ import java.util.ArrayList; import java.util.List; import java.util.Locale; +import org.lwjgl.input.Keyboard; + import com.hbm.config.GeneralConfig; import com.hbm.inventory.FluidStack; import com.hbm.inventory.RecipesCommon.AStack; @@ -148,8 +150,8 @@ public class GenericRecipe { public List print() { List list = new ArrayList(); - list.add(EnumChatFormatting.YELLOW + this.getLocalizedName()); + header(list); autoSwitch(list); duration(list); power(list); @@ -159,6 +161,11 @@ public class GenericRecipe { return list; } + protected void header(List list) { + list.add(EnumChatFormatting.YELLOW + this.getLocalizedName()); + if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) list.add(EnumChatFormatting.DARK_GRAY + "Internal: " + this.getInternalName()); + } + protected void autoSwitch(List list) { if(this.autoSwitchGroup != null) { String[] lines = I18nUtil.resolveKeyArray("autoswitch", I18nUtil.resolveKey(this.autoSwitchGroup)); diff --git a/src/main/java/com/hbm/module/ParseMSES1Ext1.java b/src/main/java/com/hbm/module/ParseMSES1Ext1.java index db4a3bc48..875c136b0 100644 --- a/src/main/java/com/hbm/module/ParseMSES1Ext1.java +++ b/src/main/java/com/hbm/module/ParseMSES1Ext1.java @@ -120,6 +120,12 @@ public class ParseMSES1Ext1 extends ParseMSES1 { return EnumStatementReturn.OK; } + // writes the total world time to the buffer + if(lower.equals("worldtime")) { + ctx.writeBuffer("" + ctx.world.getTotalWorldTime()); + return EnumStatementReturn.OK; + } + return super.eval(ctx, line); } } diff --git a/src/main/java/com/hbm/module/machine/ModuleMachineBase.java b/src/main/java/com/hbm/module/machine/ModuleMachineBase.java index 311a236fa..d75608786 100644 --- a/src/main/java/com/hbm/module/machine/ModuleMachineBase.java +++ b/src/main/java/com/hbm/module/machine/ModuleMachineBase.java @@ -25,11 +25,12 @@ public abstract class ModuleMachineBase { public FluidTank[] inputTanks; public FluidTank[] outputTanks; // running vars - public String recipe = "null"; + protected String recipe = "null"; public double progress; // return signals public boolean didProcess = false; public boolean markDirty = false; + public boolean restrictedMode = false; public ModuleMachineBase(int index, IEnergyHandlerMK2 battery, ItemStack[] slots) { this.index = index; @@ -114,6 +115,7 @@ public abstract class ModuleMachineBase { } public void process(GenericRecipe recipe, double speed, double power) { + if(this.restrictedMode) speed *= 0.25; // RoR controlled machines have a speed penalty this.battery.setPower(this.battery.getPower() - (power == 1 ? recipe.power : (long) (recipe.power * power))); double step = Math.min(speed / recipe.duration, 1D); // can't do more than one recipe per tick, might look into that later @@ -167,11 +169,20 @@ public abstract class ModuleMachineBase { this.markDirty = true; } + + public String getRecipeName() { + return this.recipe; + } public GenericRecipe getRecipe() { return (GenericRecipe) getRecipeSet().recipeNameMap.get(this.recipe); } + public void setRecipe(String name, boolean ror) { + this.recipe = name; + this.restrictedMode = ror; + } + public abstract GenericRecipes getRecipeSet(); public void update(double speed, double power, boolean extraCondition, ItemStack blueprint) { @@ -232,21 +243,25 @@ public abstract class ModuleMachineBase { public void serialize(ByteBuf buf) { buf.writeDouble(progress); + buf.writeBoolean(restrictedMode); ByteBufUtils.writeUTF8String(buf, recipe); } public void deserialize(ByteBuf buf) { this.progress = buf.readDouble(); + this.restrictedMode = buf.readBoolean(); this.recipe = ByteBufUtils.readUTF8String(buf); } public void readFromNBT(NBTTagCompound nbt) { this.progress = nbt.getDouble("progress" + index); this.recipe = nbt.getString("recipe" + index); + this.restrictedMode = nbt.getBoolean("restrictedMode"); } public void writeToNBT(NBTTagCompound nbt) { nbt.setDouble("progress" + index, progress); nbt.setString("recipe" + index, recipe); + nbt.setBoolean("restrictedMode", restrictedMode); } } diff --git a/src/main/java/com/hbm/render/tileentity/RenderAssemblyFactory.java b/src/main/java/com/hbm/render/tileentity/RenderAssemblyFactory.java index 06cdbf265..1bb80d9f0 100644 --- a/src/main/java/com/hbm/render/tileentity/RenderAssemblyFactory.java +++ b/src/main/java/com/hbm/render/tileentity/RenderAssemblyFactory.java @@ -4,7 +4,6 @@ import org.lwjgl.opengl.GL11; import com.hbm.blocks.BlockDummyable; import com.hbm.blocks.ModBlocks; -import com.hbm.inventory.recipes.AssemblyMachineRecipes; import com.hbm.inventory.recipes.loader.GenericRecipe; import com.hbm.main.MainRegistry; import com.hbm.main.ResourceManager; @@ -162,7 +161,7 @@ public class RenderAssemblyFactory extends TileEntitySpecialRenderer implements GL11.glRotated(90, 0, 1, 0); GL11.glTranslated(0, 1.0625, 0); - GenericRecipe recipe = AssemblyMachineRecipes.INSTANCE.recipeNameMap.get(assemfac.assemblerModule[i].recipe); + GenericRecipe recipe = assemfac.assemblerModule[i].getRecipe(); if(recipe != null) { ItemStack stack = recipe.getIcon(); stack.stackSize = 1; diff --git a/src/main/java/com/hbm/render/tileentity/RenderAssemblyMachine.java b/src/main/java/com/hbm/render/tileentity/RenderAssemblyMachine.java index 17eba939c..9b7407644 100644 --- a/src/main/java/com/hbm/render/tileentity/RenderAssemblyMachine.java +++ b/src/main/java/com/hbm/render/tileentity/RenderAssemblyMachine.java @@ -4,7 +4,6 @@ import org.lwjgl.opengl.GL11; import com.hbm.blocks.BlockDummyable; import com.hbm.blocks.ModBlocks; -import com.hbm.inventory.recipes.AssemblyMachineRecipes; import com.hbm.inventory.recipes.loader.GenericRecipe; import com.hbm.main.MainRegistry; import com.hbm.main.ResourceManager; @@ -99,7 +98,7 @@ public class RenderAssemblyMachine extends TileEntitySpecialRenderer implements GL11.glShadeModel(GL11.GL_FLAT); - GenericRecipe recipe = AssemblyMachineRecipes.INSTANCE.recipeNameMap.get(assembler.assemblerModule.recipe); + GenericRecipe recipe = assembler.assemblerModule.getRecipe(); if(recipe != null && MainRegistry.proxy.me().getDistanceSq(tileEntity.xCoord + 0.5, tileEntity.yCoord + 1, tileEntity.zCoord + 0.5) < 35 * 35) { GL11.glRotated(90, 0, 1, 0); diff --git a/src/main/java/com/hbm/render/tileentity/RenderChemicalPlant.java b/src/main/java/com/hbm/render/tileentity/RenderChemicalPlant.java index bd7657a69..4581d0475 100644 --- a/src/main/java/com/hbm/render/tileentity/RenderChemicalPlant.java +++ b/src/main/java/com/hbm/render/tileentity/RenderChemicalPlant.java @@ -7,7 +7,6 @@ import org.lwjgl.opengl.GL11; import com.hbm.blocks.BlockDummyable; import com.hbm.blocks.ModBlocks; import com.hbm.inventory.FluidStack; -import com.hbm.inventory.recipes.ChemicalPlantRecipes; import com.hbm.inventory.recipes.loader.GenericRecipe; import com.hbm.main.ResourceManager; import com.hbm.render.item.ItemRenderBase; @@ -39,7 +38,7 @@ public class RenderChemicalPlant extends TileEntitySpecialRenderer implements II TileEntityMachineChemicalPlant chemplant = (TileEntityMachineChemicalPlant) tileEntity; float anim = chemplant.prevAnim + (chemplant.anim - chemplant.prevAnim) * interp; - GenericRecipe recipe = ChemicalPlantRecipes.INSTANCE.recipeNameMap.get(chemplant.chemplantModule.recipe); + GenericRecipe recipe = chemplant.chemplantModule.getRecipe(); bindTexture(ResourceManager.chemical_plant_tex); ResourceManager.chemical_plant.renderPart("Base"); diff --git a/src/main/java/com/hbm/render/tileentity/RenderFusionPlasmaForge.java b/src/main/java/com/hbm/render/tileentity/RenderFusionPlasmaForge.java index 53cceadc8..9f50fc801 100644 --- a/src/main/java/com/hbm/render/tileentity/RenderFusionPlasmaForge.java +++ b/src/main/java/com/hbm/render/tileentity/RenderFusionPlasmaForge.java @@ -5,7 +5,6 @@ import org.lwjgl.opengl.GL11; import com.hbm.blocks.BlockDummyable; import com.hbm.blocks.ModBlocks; import com.hbm.inventory.fluid.Fluids; -import com.hbm.inventory.recipes.PlasmaForgeRecipes; import com.hbm.inventory.recipes.loader.GenericRecipe; import com.hbm.main.MainRegistry; import com.hbm.main.ResourceManager; @@ -62,7 +61,7 @@ public class RenderFusionPlasmaForge extends TileEntitySpecialRenderer implement bindTexture(ResourceManager.fusion_plasma_forge_tex); ResourceManager.fusion_plasma_forge.renderPart("Body"); - GenericRecipe recipe = PlasmaForgeRecipes.INSTANCE.recipeNameMap.get(forge.plasmaModule.recipe); + GenericRecipe recipe = forge.plasmaModule.getRecipe(); renderPlasma(forge); renderItem(forge, recipe, interp); diff --git a/src/main/java/com/hbm/render/tileentity/RenderPrecAss.java b/src/main/java/com/hbm/render/tileentity/RenderPrecAss.java index de84b54a4..e7a6cc2b3 100644 --- a/src/main/java/com/hbm/render/tileentity/RenderPrecAss.java +++ b/src/main/java/com/hbm/render/tileentity/RenderPrecAss.java @@ -4,7 +4,6 @@ import org.lwjgl.opengl.GL11; import com.hbm.blocks.BlockDummyable; import com.hbm.blocks.ModBlocks; -import com.hbm.inventory.recipes.PrecAssRecipes; import com.hbm.inventory.recipes.loader.GenericRecipe; import com.hbm.main.MainRegistry; import com.hbm.main.ResourceManager; @@ -71,7 +70,7 @@ public class RenderPrecAss extends TileEntitySpecialRenderer implements IItemRen GL11.glShadeModel(GL11.GL_FLAT); - GenericRecipe recipe = PrecAssRecipes.INSTANCE.recipeNameMap.get(assembler.assemblerModule.recipe); + GenericRecipe recipe = assembler.assemblerModule.getRecipe(); if(recipe != null && MainRegistry.proxy.me().getDistanceSq(tileEntity.xCoord + 0.5, tileEntity.yCoord + 1, tileEntity.zCoord + 0.5) < 35 * 35) { GL11.glRotated(90, 0, 1, 0); diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineAssemblyFactory.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineAssemblyFactory.java index 20b1e4a33..2324ba300 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineAssemblyFactory.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineAssemblyFactory.java @@ -12,7 +12,6 @@ import com.hbm.inventory.container.ContainerMachineAssemblyFactory; import com.hbm.inventory.fluid.Fluids; import com.hbm.inventory.fluid.tank.FluidTank; import com.hbm.inventory.gui.GUIMachineAssemblyFactory; -import com.hbm.inventory.recipes.AssemblyMachineRecipes; import com.hbm.inventory.recipes.loader.GenericRecipe; import com.hbm.items.ModItems; import com.hbm.items.machine.ItemMachineUpgrade; @@ -158,7 +157,7 @@ public class TileEntityMachineAssemblyFactory extends TileEntityMachineBase impl long nextMaxPower = 0; for(int i = 0; i < 4; i++) { - GenericRecipe recipe = AssemblyMachineRecipes.INSTANCE.recipeNameMap.get(assemblerModule[i].recipe); + GenericRecipe recipe = assemblerModule[i].getRecipe(); if(recipe != null) { nextMaxPower += recipe.power * 100; } @@ -374,7 +373,7 @@ public class TileEntityMachineAssemblyFactory extends TileEntityMachineBase impl int index = data.getInteger("index"); String selection = data.getString("selection"); if(index >= 0 && index < 4) { - this.assemblerModule[index].recipe = selection; + this.assemblerModule[index].setRecipe(selection, false); this.markChanged(); } } diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineAssemblyMachine.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineAssemblyMachine.java index 721cd9031..0592ad79e 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineAssemblyMachine.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineAssemblyMachine.java @@ -11,7 +11,6 @@ import com.hbm.inventory.container.ContainerMachineAssemblyMachine; import com.hbm.inventory.fluid.Fluids; import com.hbm.inventory.fluid.tank.FluidTank; import com.hbm.inventory.gui.GUIMachineAssemblyMachine; -import com.hbm.inventory.recipes.AssemblyMachineRecipes; import com.hbm.inventory.recipes.loader.GenericRecipe; import com.hbm.items.ModItems; import com.hbm.items.machine.ItemMachineUpgrade; @@ -30,6 +29,8 @@ import com.hbm.util.i18n.I18nUtil; import api.hbm.energymk2.IEnergyReceiverMK2; import api.hbm.fluidmk2.IFluidStandardTransceiverMK2; +import api.hbm.redstoneoverradio.IRORInteractive; +import api.hbm.redstoneoverradio.IRORValueProvider; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import io.netty.buffer.ByteBuf; @@ -41,7 +42,7 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; -public class TileEntityMachineAssemblyMachine extends TileEntityMachineBase implements IEnergyReceiverMK2, IFluidStandardTransceiverMK2, IUpgradeInfoProvider, IControlReceiver, IGUIProvider { +public class TileEntityMachineAssemblyMachine extends TileEntityMachineBase implements IEnergyReceiverMK2, IFluidStandardTransceiverMK2, IUpgradeInfoProvider, IControlReceiver, IGUIProvider, IRORValueProvider, IRORInteractive { public FluidTank inputTank; public FluidTank outputTank; @@ -88,7 +89,7 @@ public class TileEntityMachineAssemblyMachine extends TileEntityMachineBase impl if(!worldObj.isRemote) { - GenericRecipe recipe = AssemblyMachineRecipes.INSTANCE.recipeNameMap.get(assemblerModule.recipe); + GenericRecipe recipe = assemblerModule.getRecipe(); if(recipe != null) { this.maxPower = recipe.power * 100; } @@ -303,7 +304,7 @@ public class TileEntityMachineAssemblyMachine extends TileEntityMachineBase impl int index = data.getInteger("index"); String selection = data.getString("selection"); if(index == 0) { - this.assemblerModule.recipe = selection; + this.assemblerModule.setRecipe(selection, false); this.markChanged(); } } @@ -482,4 +483,34 @@ public class TileEntityMachineAssemblyMachine extends TileEntityMachineBase impl }; } } + + @Override + public String[] getFunctionInfo() { + return new String[] { + PREFIX_VALUE + "progress", + PREFIX_VALUE + "recipe", + PREFIX_VALUE + "active", + PREFIX_FUNCTION + "setrecipe" + NAME_SEPARATOR + "name", + }; + } + + @Override + public String provideRORValue(String name) { + if("progress".equals(name)) return "" + (int) Math.round(this.assemblerModule.progress * 100); + if("recipe".equals(name)) return this.assemblerModule.getRecipeName(); + if("active".equals(name)) return "" + (this.didProcess ? 1 : 0); + return null; + } + + @Override + public String runRORFunction(String name, String[] params) { + + if("setrecipe".equals(name) && params.length == 1) { + this.assemblerModule.setRecipe(params[0], true); + this.markChanged(); + return null; + } + + return null; + } } diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemicalFactory.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemicalFactory.java index 8f0e8a905..2f1c80eb4 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemicalFactory.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemicalFactory.java @@ -10,7 +10,6 @@ import com.hbm.inventory.container.ContainerMachineChemicalFactory; import com.hbm.inventory.fluid.Fluids; import com.hbm.inventory.fluid.tank.FluidTank; import com.hbm.inventory.gui.GUIMachineChemicalFactory; -import com.hbm.inventory.recipes.ChemicalPlantRecipes; import com.hbm.inventory.recipes.loader.GenericRecipe; import com.hbm.items.ModItems; import com.hbm.items.machine.ItemMachineUpgrade; @@ -158,7 +157,7 @@ public class TileEntityMachineChemicalFactory extends TileEntityMachineBase impl long nextMaxPower = 0; for(int i = 0; i < 4; i++) { - GenericRecipe recipe = ChemicalPlantRecipes.INSTANCE.recipeNameMap.get(chemplantModule[i].recipe); + GenericRecipe recipe = chemplantModule[i].getRecipe(); if(recipe != null) { nextMaxPower += recipe.power * 100; } @@ -400,7 +399,7 @@ public class TileEntityMachineChemicalFactory extends TileEntityMachineBase impl int index = data.getInteger("index"); String selection = data.getString("selection"); if(index >= 0 && index < 4) { - this.chemplantModule[index].recipe = selection; + this.chemplantModule[index].setRecipe(selection, false); this.markChanged(); } } diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemicalPlant.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemicalPlant.java index b4c730928..50e779f1c 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemicalPlant.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemicalPlant.java @@ -10,7 +10,6 @@ import com.hbm.inventory.container.ContainerMachineChemicalPlant; import com.hbm.inventory.fluid.Fluids; import com.hbm.inventory.fluid.tank.FluidTank; import com.hbm.inventory.gui.GUIMachineChemicalPlant; -import com.hbm.inventory.recipes.ChemicalPlantRecipes; import com.hbm.inventory.recipes.loader.GenericRecipe; import com.hbm.items.ModItems; import com.hbm.items.machine.ItemMachineUpgrade; @@ -86,7 +85,7 @@ public class TileEntityMachineChemicalPlant extends TileEntityMachineBase implem if(!worldObj.isRemote) { - GenericRecipe recipe = ChemicalPlantRecipes.INSTANCE.recipeNameMap.get(chemplantModule.recipe); + GenericRecipe recipe = chemplantModule.getRecipe(); if(recipe != null) { this.maxPower = recipe.power * 100; } @@ -278,7 +277,7 @@ public class TileEntityMachineChemicalPlant extends TileEntityMachineBase implem int index = data.getInteger("index"); String selection = data.getString("selection"); if(index == 0) { - this.chemplantModule.recipe = selection; + this.chemplantModule.setRecipe(selection, false); this.markChanged(); } } diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachinePUREX.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachinePUREX.java index 0aca4f5b6..6f20e2e69 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachinePUREX.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachinePUREX.java @@ -10,7 +10,6 @@ import com.hbm.inventory.container.ContainerMachinePUREX; import com.hbm.inventory.fluid.Fluids; import com.hbm.inventory.fluid.tank.FluidTank; import com.hbm.inventory.gui.GUIMachinePUREX; -import com.hbm.inventory.recipes.PUREXRecipes; import com.hbm.inventory.recipes.loader.GenericRecipe; import com.hbm.items.ModItems; import com.hbm.items.machine.ItemMachineUpgrade; @@ -80,7 +79,7 @@ public class TileEntityMachinePUREX extends TileEntityMachineBase implements IEn if(!worldObj.isRemote) { - GenericRecipe recipe = PUREXRecipes.INSTANCE.recipeNameMap.get(purexModule.recipe); + GenericRecipe recipe = purexModule.getRecipe(); if(recipe != null) { this.maxPower = recipe.power * 100; } @@ -235,7 +234,7 @@ public class TileEntityMachinePUREX extends TileEntityMachineBase implements IEn int index = data.getInteger("index"); String selection = data.getString("selection"); if(index == 0) { - this.purexModule.recipe = selection; + this.purexModule.setRecipe(selection, false); this.markChanged(); } } diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachinePrecAss.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachinePrecAss.java index b8429c2e5..c441bff3e 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachinePrecAss.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachinePrecAss.java @@ -10,7 +10,6 @@ import com.hbm.inventory.container.ContainerMachinePrecAss; import com.hbm.inventory.fluid.Fluids; import com.hbm.inventory.fluid.tank.FluidTank; import com.hbm.inventory.gui.GUIMachinePrecAss; -import com.hbm.inventory.recipes.PrecAssRecipes; import com.hbm.inventory.recipes.loader.GenericRecipe; import com.hbm.items.ModItems; import com.hbm.items.machine.ItemMachineUpgrade; @@ -93,7 +92,7 @@ public class TileEntityMachinePrecAss extends TileEntityMachineBase implements I if(!worldObj.isRemote) { - GenericRecipe recipe = PrecAssRecipes.INSTANCE.recipeNameMap.get(assemblerModule.recipe); + GenericRecipe recipe = assemblerModule.getRecipe(); if(recipe != null) { this.maxPower = recipe.power * 100; } @@ -352,7 +351,7 @@ public class TileEntityMachinePrecAss extends TileEntityMachineBase implements I int index = data.getInteger("index"); String selection = data.getString("selection"); if(index == 0) { - this.assemblerModule.recipe = selection; + this.assemblerModule.setRecipe(selection, false); this.markChanged(); } } diff --git a/src/main/java/com/hbm/tileentity/machine/fusion/TileEntityFusionPlasmaForge.java b/src/main/java/com/hbm/tileentity/machine/fusion/TileEntityFusionPlasmaForge.java index 9d8cf978c..3ac9468d1 100644 --- a/src/main/java/com/hbm/tileentity/machine/fusion/TileEntityFusionPlasmaForge.java +++ b/src/main/java/com/hbm/tileentity/machine/fusion/TileEntityFusionPlasmaForge.java @@ -16,7 +16,6 @@ import com.hbm.inventory.fluid.Fluids; import com.hbm.inventory.fluid.tank.FluidTank; import com.hbm.inventory.gui.GUIMachinePlasmaForge; import com.hbm.inventory.recipes.PlasmaForgeRecipe; -import com.hbm.inventory.recipes.PlasmaForgeRecipes; import com.hbm.items.ModItems; import com.hbm.lib.Library; import com.hbm.main.MainRegistry; @@ -156,7 +155,7 @@ public class TileEntityFusionPlasmaForge extends TileEntityMachineBase implement if(receiverNode != null && receiverNode.hasValidNet()) receiverNode.net.addReceiver(this); if(providerNode != null && providerNode.hasValidNet()) providerNode.net.addProvider(this); // technically unused, but good to have when we do something else with the plasma nets - PlasmaForgeRecipe recipe = (PlasmaForgeRecipe) PlasmaForgeRecipes.INSTANCE.recipeNameMap.get(plasmaModule.recipe); + PlasmaForgeRecipe recipe = (PlasmaForgeRecipe) plasmaModule.getRecipe(); if(recipe != null) this.maxPower = recipe.power * 100; this.maxPower = BobMathUtil.max(this.power, this.maxPower, 100_000); @@ -364,7 +363,7 @@ public class TileEntityFusionPlasmaForge extends TileEntityMachineBase implement int index = data.getInteger("index"); String selection = data.getString("selection"); if(index == 0) { - this.plasmaModule.recipe = selection; + this.plasmaModule.setRecipe(selection, false); this.markChanged(); } } diff --git a/src/main/java/com/hbm/tileentity/machine/fusion/TileEntityFusionTorus.java b/src/main/java/com/hbm/tileentity/machine/fusion/TileEntityFusionTorus.java index 9208fab1f..b278623fe 100644 --- a/src/main/java/com/hbm/tileentity/machine/fusion/TileEntityFusionTorus.java +++ b/src/main/java/com/hbm/tileentity/machine/fusion/TileEntityFusionTorus.java @@ -473,7 +473,7 @@ public class TileEntityFusionTorus extends TileEntityCooledBase implements IGUIP int index = data.getInteger("index"); String selection = data.getString("selection"); if(index == 0) { - this.fusionModule.recipe = selection; + this.fusionModule.setRecipe(selection, false); this.markChanged(); } } diff --git a/src/main/java/com/hbm/tileentity/network/pneumatic/TileEntityPneumoStorageExporter.java b/src/main/java/com/hbm/tileentity/network/pneumatic/TileEntityPneumoStorageExporter.java index 2c01aff94..b639fbb56 100644 --- a/src/main/java/com/hbm/tileentity/network/pneumatic/TileEntityPneumoStorageExporter.java +++ b/src/main/java/com/hbm/tileentity/network/pneumatic/TileEntityPneumoStorageExporter.java @@ -4,7 +4,9 @@ package com.hbm.tileentity.network.pneumatic; import com.hbm.interfaces.IControlReceiver; import com.hbm.inventory.container.ContainerPneumoStorageExporter; import com.hbm.inventory.gui.GUIPneumoStorageExporter; +import com.hbm.tileentity.network.RTTYSystem; +import api.hbm.ntl.StackCache.CacheSlot; import api.hbm.redstoneoverradio.IRORInteractive; import io.netty.buffer.ByteBuf; import net.minecraft.entity.player.EntityPlayer; @@ -20,8 +22,8 @@ public class TileEntityPneumoStorageExporter extends TileEntityPneumaticMachineB public boolean rorConfiguredMode = false; /** What strategy to use for handling request filters */ public int requestMode = 0; - /** Item ID and meta pairs for RoR controlled filters */ - public short[][] rorFilters = new short[9][2]; + /** Item ID and meta pairs with amount for RoR controlled filters */ + public short[][] rorFilters = new short[9][3]; /** Each slot individually tries to pull as much as it can of the configured item */ public static final int MODE_AS_MUCH_AS_POSSIBLE = 0; @@ -47,6 +49,23 @@ public class TileEntityPneumoStorageExporter extends TileEntityPneumaticMachineB this.networkPackNT(15); } } + + public void doRequest(boolean force) { + + } + + public void requestSlot(int slot, boolean force) { + + } + + public long getAvailability(int item, int meta) { + if(this.cache == null || this.cache.hasExpired) return 0; + long hash = this.cache.getStackIdentity(item, meta, null); + if(hash == this.cache.getNullIdentity()) return 0; + CacheSlot slot = this.cache.cacheSlots.get(hash); + if(slot == null) return 0; + return slot.stacksize; + } @Override public void serialize(ByteBuf buf) { @@ -57,6 +76,7 @@ public class TileEntityPneumoStorageExporter extends TileEntityPneumaticMachineB for(int i = 0; i < 9; i++) { buf.writeShort(rorFilters[i][0]); buf.writeShort(rorFilters[i][1]); + buf.writeShort(rorFilters[i][2]); } } @@ -69,6 +89,7 @@ public class TileEntityPneumoStorageExporter extends TileEntityPneumaticMachineB for(int i = 0; i < 9; i++) { rorFilters[i][0] = buf.readShort(); rorFilters[i][1] = buf.readShort(); + rorFilters[i][2] = buf.readShort(); } } @@ -96,7 +117,7 @@ public class TileEntityPneumoStorageExporter extends TileEntityPneumaticMachineB public String[] getFunctionInfo() { return new String[] { PREFIX_FUNCTION + "setfilter" + NAME_SEPARATOR + "slot" + PARAM_SEPARATOR + "itemid" + PARAM_SEPARATOR + "itemmeta" + PARAM_SEPARATOR + "amount", - PREFIX_FUNCTION + "setcontinuous" + NAME_SEPARATOR + "slot" + PARAM_SEPARATOR + "itemid" + PARAM_SEPARATOR + "itemmeta" + PARAM_SEPARATOR + "amount", + PREFIX_FUNCTION + "setcontinuous" + NAME_SEPARATOR + "on/off", PREFIX_FUNCTION + "request", PREFIX_FUNCTION + "requestslot" + NAME_SEPARATOR + "slot", PREFIX_FUNCTION + "checkavailability" + NAME_SEPARATOR + "itemid" + PARAM_SEPARATOR + "itemmeta" + PARAM_SEPARATOR + "returnchannel", @@ -105,6 +126,47 @@ public class TileEntityPneumoStorageExporter extends TileEntityPneumaticMachineB @Override public String runRORFunction(String name, String[] params) { + + if("setfilter".equals(name) && params.length == 4) { + int slot = IRORInteractive.parseInt(params[0], 1, 9) - 1; + int itemId = IRORInteractive.parseInt(params[1], 0, Short.MAX_VALUE); + int meta = IRORInteractive.parseInt(params[2], 0, Short.MAX_VALUE); + int amount = IRORInteractive.parseInt(params[3], 1, 64); + + this.rorFilters[slot][0] = (short) itemId; + this.rorFilters[slot][1] = (short) meta; + this.rorFilters[slot][2] = (short) amount; + this.markChanged(); + return null; + } + + if("setcontinuous".equals(name) && params.length == 1) { + if("on".equals(params[0])) this.continuousRequest = true; + if("off".equals(params[0])) this.continuousRequest = false; + this.markChanged(); + return null; + } + + if("request".equals(name)) { + this.doRequest(true); + return null; + } + + if("requestslot".equals(name) && params.length == 1) { + int slot = IRORInteractive.parseInt(params[0], 1, 9) - 1; + this.requestSlot(slot, true); + return null; + } + + if("checkavailability".equals(name) && params.length == 3) { + int itemId = IRORInteractive.parseInt(params[0], 0, Short.MAX_VALUE); + int meta = IRORInteractive.parseInt(params[1], 0, Short.MAX_VALUE); + String ret = params[2]; + long availability = this.getAvailability(itemId, meta); + RTTYSystem.broadcast(worldObj, ret, availability + ""); + return null; + } + return null; } } diff --git a/src/main/resources/assets/hbm/textures/gui/processing/gui_chemplant.png b/src/main/resources/assets/hbm/textures/gui/processing/gui_chemplant.png index 3ce1bc32c..b5435bfee 100644 Binary files a/src/main/resources/assets/hbm/textures/gui/processing/gui_chemplant.png and b/src/main/resources/assets/hbm/textures/gui/processing/gui_chemplant.png differ