diff --git a/changelog b/changelog index 9ca5b6b0c..d1aa96597 100644 --- a/changelog +++ b/changelog @@ -24,7 +24,7 @@ * Added an alternate chemical plant recipe that uses a smaller selection of items and ICs instead of ACs * Flashgold and flashlead are now made in the PUREX instead of the crafting table * The flashgold recipe now yields two billets instead of one -* Slightly changed the HSS ingot texture to not look identical to steel except slightly greenish +* Slightly changed the HSS ingot and plate textures to not look identical to steel except slightly greenish * The AUTOCAL's buffer is now limited to 256 characters instead of being infinite * 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 @@ -35,13 +35,16 @@ * 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 -* Assembly recipes and chemical factories can now be read (but not configured) using Redstone-over-Radio -* The factories script interpreter now runs MS-ES v1.1 (First Extended Instruction Set) +* Assembly factories, chemical factories, PUREX and plasma forges can now be read (but not configured) using Redstone-over-Radio +* Fusion reactor vessels can now be read and configured using RoR + * Unlike assemblers and chemplants, remote recipe configuration does not cause a speed penalty +* 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 +* All RoR values/commands are now case-insensitive ## Fixed * Fixed AUTOCAL's number comparison functions not working with variable substitution as advertised @@ -52,4 +55,4 @@ * Fixed some recipes not using ore dict when they should * Fixed `anyBismoid` group not being a proper group, causing other mods' bismuth and arsenic to not be included * Fixed RoR gauge not using SI suffixes on values below 0 -* Fixed AUTOCAL units not closing their GUI when the unit is destroyed \ No newline at end of file +* Fixed AUTOCAL units not closing their GUI when the unit is destroyed diff --git a/src/main/java/api/hbm/redstoneoverradio/IRORInteractive.java b/src/main/java/api/hbm/redstoneoverradio/IRORInteractive.java index 518b23c87..37819b5df 100644 --- a/src/main/java/api/hbm/redstoneoverradio/IRORInteractive.java +++ b/src/main/java/api/hbm/redstoneoverradio/IRORInteractive.java @@ -1,5 +1,7 @@ package api.hbm.redstoneoverradio; +import java.util.Locale; + public interface IRORInteractive extends IRORInfo { public static String NAME_SEPARATOR = "!"; @@ -18,7 +20,7 @@ public interface IRORInteractive extends IRORInfo { String[] parts = input.split(NAME_SEPARATOR); if(parts.length <= 0 || parts.length > 2) throw new RORFunctionException(EX_NAME); if(parts[0].isEmpty()) throw new RORFunctionException(EX_NULL); - return parts[0]; + return parts[0].toLowerCase(Locale.US); } /** Extracts the param list from a full command string */ diff --git a/src/main/java/com/hbm/inventory/recipes/loader/GenericRecipes.java b/src/main/java/com/hbm/inventory/recipes/loader/GenericRecipes.java index 6bc4d93e1..6fee43971 100644 --- a/src/main/java/com/hbm/inventory/recipes/loader/GenericRecipes.java +++ b/src/main/java/com/hbm/inventory/recipes/loader/GenericRecipes.java @@ -48,7 +48,7 @@ public abstract class GenericRecipes extends Serializab /** Blueprint pool name to list of recipe names that are part of this pool */ public static HashMap> blueprintPools = new HashMap(); /** Name to recipe map for all recipes that are part of pools for lookup */ - public static HashMap pooledBlueprints = new HashMap(); + public static HashMap nameToRecipeGlobal = new HashMap(); /** Groups for auto switch functionality (changes recipe automatically based on first solid input) */ public HashMap> autoSwitchGroups = new HashMap(); @@ -68,7 +68,6 @@ public abstract class GenericRecipes extends Serializab blueprintPools.put(pool, list); } list.add(recipe.name); - pooledBlueprints.put(recipe.name, recipe); } /** Adds a recipe to an auto switch group (recipe can switch based on first solid input) */ @@ -81,7 +80,7 @@ public abstract class GenericRecipes extends Serializab public static void clearPools() { blueprintPools.clear(); - pooledBlueprints.clear(); + nameToRecipeGlobal.clear(); } @Override @@ -100,6 +99,7 @@ public abstract class GenericRecipes extends Serializab this.recipeOrderedList.add(recipe); if(recipeNameMap.containsKey(recipe.name)) throw new IllegalStateException("Recipe " + recipe.name + " has been registered with a duplicate ID!"); this.recipeNameMap.put(recipe.name, recipe); + nameToRecipeGlobal.put(recipe.name, recipe); } @Override diff --git a/src/main/java/com/hbm/items/machine/ItemBlueprints.java b/src/main/java/com/hbm/items/machine/ItemBlueprints.java index fc6c960ac..07be9a219 100644 --- a/src/main/java/com/hbm/items/machine/ItemBlueprints.java +++ b/src/main/java/com/hbm/items/machine/ItemBlueprints.java @@ -121,7 +121,7 @@ public class ItemBlueprints extends Item { } for(String name : pool) { - GenericRecipe recipe = GenericRecipes.pooledBlueprints.get(name); + GenericRecipe recipe = GenericRecipes.nameToRecipeGlobal.get(name); if(recipe != null) { list.add(recipe.getLocalizedName()); } diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityHeaterOilburner.java b/src/main/java/com/hbm/tileentity/machine/TileEntityHeaterOilburner.java index bdeb8bedd..4706bae84 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityHeaterOilburner.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityHeaterOilburner.java @@ -244,8 +244,8 @@ public class TileEntityHeaterOilburner extends TileEntityMachinePolluting implem PREFIX_VALUE + "fuel", PREFIX_VALUE + "burnRate", PREFIX_VALUE + "state", - PREFIX_FUNCTION + "setState" + NAME_SEPARATOR + "active", - PREFIX_FUNCTION + "setBurnRate" + NAME_SEPARATOR + "rate" + PREFIX_FUNCTION + "setstate" + NAME_SEPARATOR + "active", + PREFIX_FUNCTION + "setburnrate" + NAME_SEPARATOR + "rate" }; } @@ -253,29 +253,23 @@ public class TileEntityHeaterOilburner extends TileEntityMachinePolluting implem public String provideRORValue(String name) { if((PREFIX_VALUE + "heat").equals(name)) return "" + heatEnergy; if((PREFIX_VALUE + "fuel").equals(name)) return "" + tank.getFill(); - if((PREFIX_VALUE + "burnRate").equals(name)) return "" + setting; + if((PREFIX_VALUE + "burnrate").equals(name)) return "" + setting; if((PREFIX_VALUE + "state").equals(name)) return isOn ? "1" : "0"; return null; } @Override public String runRORFunction(String name, String[] params) { - if((PREFIX_FUNCTION + "setState").equals(name)) { + if((PREFIX_FUNCTION + "setstate").equals(name)) { this.isOn = params[0].equals("1"); this.markChanged(); return null; } - if((PREFIX_FUNCTION + "setBurnRate").equals(name)) { - try { - int rate = Integer.parseInt(params[0]); - if(rate < 1) rate = 1; - if(rate > 10) rate = 10; - this.setting = rate; - this.markChanged(); - return null; - } catch (NumberFormatException e) { - return "Invalid number"; - } + if((PREFIX_FUNCTION + "setburnrate").equals(name)) { + int rate = IRORInteractive.parseInt(params[0], 1, 10); + this.setting = rate; + this.markChanged(); + return null; } return null; } diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineAssemblyFactory.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineAssemblyFactory.java index e171deb1a..c7010af97 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineAssemblyFactory.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineAssemblyFactory.java @@ -744,11 +744,11 @@ public class TileEntityMachineAssemblyFactory extends TileEntityMachineBase impl @Override public String provideRORValue(String name) { - if("anyactive".equals(name)) return "" + ((this.didProcess[0] || this.didProcess[1] || this.didProcess[2] || this.didProcess[3]) ? 1 : 0); + if((PREFIX_VALUE + "anyactive").equals(name)) return "" + ((this.didProcess[0] || this.didProcess[1] || this.didProcess[2] || this.didProcess[3]) ? 1 : 0); for(int i = 0; i < 4; i++) { - if(("progress" + i).equals(name)) return "" + (int) Math.round(this.assemblerModule[i].progress * 100); - if(("recipe" + i).equals(name)) return this.assemblerModule[i].getRecipeName(); - if(("active" + i).equals(name)) return "" + (this.didProcess[i] ? 1 : 0); + if((PREFIX_VALUE + "progress" + i).equals(name)) return "" + (int) Math.round(this.assemblerModule[i].progress * 100); + if((PREFIX_VALUE + "recipe" + i).equals(name)) return this.assemblerModule[i].getRecipeName(); + if((PREFIX_VALUE + "active" + i).equals(name)) return "" + (this.didProcess[i] ? 1 : 0); } return null; } diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineAssemblyMachine.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineAssemblyMachine.java index 0592ad79e..486dbe8c4 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineAssemblyMachine.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineAssemblyMachine.java @@ -496,16 +496,16 @@ public class TileEntityMachineAssemblyMachine extends TileEntityMachineBase impl @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); + if((PREFIX_VALUE + "progress").equals(name)) return "" + (int) Math.round(this.assemblerModule.progress * 100); + if((PREFIX_VALUE + "recipe").equals(name)) return this.assemblerModule.getRecipeName(); + if((PREFIX_VALUE + "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) { + + if((PREFIX_FUNCTION + "setrecipe").equals(name) && params.length == 1) { this.assemblerModule.setRecipe(params[0], true); this.markChanged(); 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 2042d0615..7e2a170b8 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemicalFactory.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemicalFactory.java @@ -502,11 +502,11 @@ public class TileEntityMachineChemicalFactory extends TileEntityMachineBase impl @Override public String provideRORValue(String name) { - if("anyactive".equals(name)) return "" + ((this.didProcess[0] || this.didProcess[1] || this.didProcess[2] || this.didProcess[3]) ? 1 : 0); + if((PREFIX_VALUE + "anyactive").equals(name)) return "" + ((this.didProcess[0] || this.didProcess[1] || this.didProcess[2] || this.didProcess[3]) ? 1 : 0); for(int i = 0; i < 4; i++) { - if(("progress" + i).equals(name)) return "" + (int) Math.round(this.chemplantModule[i].progress * 100); - if(("recipe" + i).equals(name)) return this.chemplantModule[i].getRecipeName(); - if(("active" + i).equals(name)) return "" + (this.didProcess[i] ? 1 : 0); + if((PREFIX_VALUE + "progress" + i).equals(name)) return "" + (int) Math.round(this.chemplantModule[i].progress * 100); + if((PREFIX_VALUE + "recipe" + i).equals(name)) return this.chemplantModule[i].getRecipeName(); + if((PREFIX_VALUE + "active" + i).equals(name)) return "" + (this.didProcess[i] ? 1 : 0); } return null; } diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemicalPlant.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemicalPlant.java index d40881054..8c52695e9 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemicalPlant.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemicalPlant.java @@ -340,16 +340,16 @@ public class TileEntityMachineChemicalPlant extends TileEntityMachineBase implem @Override public String provideRORValue(String name) { - if("progress".equals(name)) return "" + (int) Math.round(this.chemplantModule.progress * 100); - if("recipe".equals(name)) return this.chemplantModule.getRecipeName(); - if("active".equals(name)) return "" + (this.didProcess ? 1 : 0); + if((PREFIX_VALUE + "progress").equals(name)) return "" + (int) Math.round(this.chemplantModule.progress * 100); + if((PREFIX_VALUE + "recipe").equals(name)) return this.chemplantModule.getRecipeName(); + if((PREFIX_VALUE + "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) { + + if((PREFIX_FUNCTION + "setrecipe").equals(name) && params.length == 1) { this.chemplantModule.setRecipe(params[0], true); this.markChanged(); return null; diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineCombustionEngine.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineCombustionEngine.java index edad59cd9..e6214bb64 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineCombustionEngine.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineCombustionEngine.java @@ -484,8 +484,8 @@ public class TileEntityMachineCombustionEngine extends TileEntityMachinePollutin PREFIX_VALUE + "power", PREFIX_VALUE + "fuel", PREFIX_VALUE + "efficiency", - PREFIX_FUNCTION + "setState" + NAME_SEPARATOR + "state", - PREFIX_FUNCTION + "setThrottle" + NAME_SEPARATOR + "throttle" + PREFIX_FUNCTION + "setstate" + NAME_SEPARATOR + "state", + PREFIX_FUNCTION + "setthrottle" + NAME_SEPARATOR + "throttle" }; } @@ -509,7 +509,7 @@ public class TileEntityMachineCombustionEngine extends TileEntityMachinePollutin @Override public String runRORFunction(String name, String[] params) { - if ((PREFIX_FUNCTION + "setState").equals(name) && params.length > 0) { + if ((PREFIX_FUNCTION + "setstate").equals(name) && params.length > 0) { try { int val = Integer.parseInt(params[0]); this.isOn = (val == 1); @@ -517,7 +517,7 @@ public class TileEntityMachineCombustionEngine extends TileEntityMachinePollutin } catch (NumberFormatException e) {} return null; } - if ((PREFIX_FUNCTION + "setThrottle").equals(name) && params.length > 0) { + if ((PREFIX_FUNCTION + "setthrottle").equals(name) && params.length > 0) { try { int val = Integer.parseInt(params[0]); if (val < 0) val = 0; diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachinePUREX.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachinePUREX.java index 6f20e2e69..0181ac59a 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachinePUREX.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachinePUREX.java @@ -25,6 +25,7 @@ import com.hbm.util.i18n.I18nUtil; import api.hbm.energymk2.IEnergyReceiverMK2; import api.hbm.fluidmk2.IFluidStandardTransceiverMK2; +import api.hbm.redstoneoverradio.IRORValueProvider; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import io.netty.buffer.ByteBuf; @@ -36,7 +37,7 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; -public class TileEntityMachinePUREX extends TileEntityMachineBase implements IEnergyReceiverMK2, IFluidStandardTransceiverMK2, IUpgradeInfoProvider, IControlReceiver, IGUIProvider { +public class TileEntityMachinePUREX extends TileEntityMachineBase implements IEnergyReceiverMK2, IFluidStandardTransceiverMK2, IUpgradeInfoProvider, IControlReceiver, IGUIProvider, IRORValueProvider { public FluidTank[] inputTanks; public FluidTank[] outputTanks; @@ -282,4 +283,21 @@ public class TileEntityMachinePUREX extends TileEntityMachineBase implements IEn upgrades.put(UpgradeType.OVERDRIVE, 3); return upgrades; } + + @Override + public String[] getFunctionInfo() { + return new String[] { + PREFIX_VALUE + "progress", + PREFIX_VALUE + "recipe", + PREFIX_VALUE + "active", + }; + } + + @Override + public String provideRORValue(String name) { + if((PREFIX_VALUE + "progress").equals(name)) return "" + (int) Math.round(this.purexModule.progress * 100); + if((PREFIX_VALUE + "recipe").equals(name)) return this.purexModule.getRecipeName(); + if((PREFIX_VALUE + "active").equals(name)) return "" + (this.didProcess ? 1 : 0); + return null; + } } diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineTurbineGas.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineTurbineGas.java index 47040e264..51c726fd5 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineTurbineGas.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineTurbineGas.java @@ -737,16 +737,16 @@ public class TileEntityMachineTurbineGas extends TileEntityMachineBase implement PREFIX_VALUE + "turbinespeed", PREFIX_VALUE + "output", PREFIX_VALUE + "state", - PREFIX_VALUE + "autoMode", + PREFIX_VALUE + "automode", PREFIX_VALUE + "temp", PREFIX_VALUE + "power", PREFIX_VALUE + "fuel", PREFIX_VALUE + "lubricant", PREFIX_VALUE + "water", PREFIX_VALUE + "steam", - PREFIX_FUNCTION + "setAuto" + NAME_SEPARATOR + "auto", - PREFIX_FUNCTION + "setThrottle" + NAME_SEPARATOR + "percent", - PREFIX_FUNCTION + "setState" + NAME_SEPARATOR + "state" + PREFIX_FUNCTION + "setauto" + NAME_SEPARATOR + "auto", + PREFIX_FUNCTION + "setthrottle" + NAME_SEPARATOR + "percent", + PREFIX_FUNCTION + "setstate" + NAME_SEPARATOR + "state" }; } @@ -756,7 +756,7 @@ public class TileEntityMachineTurbineGas extends TileEntityMachineBase implement if((PREFIX_VALUE + "turbinespeed").equals(name)) return "" + this.rpm; if((PREFIX_VALUE + "output").equals(name)) return "" + (int) (this.instantPowerOutput * 20); if((PREFIX_VALUE + "state").equals(name)) return "" + this.state; - if((PREFIX_VALUE + "autoMode").equals(name)) return "" + (this.autoMode ? 1 : 0); + if((PREFIX_VALUE + "automode").equals(name)) return "" + (this.autoMode ? 1 : 0); if((PREFIX_VALUE + "temp").equals(name)) return "" + this.temp; if((PREFIX_VALUE + "power").equals(name)) return "" + this.power; if((PREFIX_VALUE + "fuel").equals(name)) return "" + tanks[0].getFill(); @@ -768,7 +768,7 @@ public class TileEntityMachineTurbineGas extends TileEntityMachineBase implement @Override public String runRORFunction(String name, String[] params) { - if((PREFIX_FUNCTION + "setAuto").equals(name) && params.length > 0) { + if((PREFIX_FUNCTION + "setauto").equals(name) && params.length > 0) { try { int val = Integer.parseInt(params[0]); this.autoMode = (val == 1); @@ -776,7 +776,7 @@ public class TileEntityMachineTurbineGas extends TileEntityMachineBase implement } catch(NumberFormatException e) {} return null; } - if((PREFIX_FUNCTION + "setThrottle").equals(name) && params.length > 0) { + if((PREFIX_FUNCTION + "setthrottle").equals(name) && params.length > 0) { try { int percent = Integer.parseInt(params[0]); if(percent < 0) percent = 0; @@ -786,7 +786,7 @@ public class TileEntityMachineTurbineGas extends TileEntityMachineBase implement } catch(NumberFormatException e) {} return null; } - if((PREFIX_FUNCTION + "setState").equals(name) && params.length > 0) { + if((PREFIX_FUNCTION + "setstate").equals(name) && params.length > 0) { try { int newState = Integer.parseInt(params[0]); if(newState == 1) { diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityReactorZirnox.java b/src/main/java/com/hbm/tileentity/machine/TileEntityReactorZirnox.java index 30a686426..93293c4d9 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityReactorZirnox.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityReactorZirnox.java @@ -616,8 +616,8 @@ public class TileEntityReactorZirnox extends TileEntityMachineBase implements IC PREFIX_VALUE + "steam", PREFIX_VALUE + "co2", PREFIX_VALUE + "state", - PREFIX_FUNCTION + "setState" + NAME_SEPARATOR + "active (0 or 1)", - PREFIX_FUNCTION + "ventCO2" + PREFIX_FUNCTION + "setstate" + NAME_SEPARATOR + "active (0 or 1)", + PREFIX_FUNCTION + "ventco2" }; } @@ -634,7 +634,7 @@ public class TileEntityReactorZirnox extends TileEntityMachineBase implements IC @Override public String runRORFunction(String name, String[] params) { - if((PREFIX_FUNCTION + "setState").equals(name) && params.length > 0) { + if((PREFIX_FUNCTION + "setstate").equals(name) && params.length > 0) { if(redstonePowered) return null; try { int val = Integer.parseInt(params[0]); @@ -643,7 +643,7 @@ public class TileEntityReactorZirnox extends TileEntityMachineBase implements IC } catch(NumberFormatException e) {} return null; } - if ((PREFIX_FUNCTION + "ventCO2").equals(name)) { + if ((PREFIX_FUNCTION + "ventco2").equals(name)) { int fill = this.carbonDioxide.getFill(); this.carbonDioxide.setFill(Math.max(fill - 1000, 0)); this.markDirty(); 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 3ac9468d1..1b49f2dc4 100644 --- a/src/main/java/com/hbm/tileentity/machine/fusion/TileEntityFusionPlasmaForge.java +++ b/src/main/java/com/hbm/tileentity/machine/fusion/TileEntityFusionPlasmaForge.java @@ -33,6 +33,7 @@ import com.hbm.util.fauxpointtwelve.DirPos; import api.hbm.energymk2.IEnergyReceiverMK2; import api.hbm.fluidmk2.IFluidStandardReceiverMK2; +import api.hbm.redstoneoverradio.IRORValueProvider; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import io.netty.buffer.ByteBuf; @@ -44,7 +45,7 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityFusionPlasmaForge extends TileEntityMachineBase implements IFusionPowerReceiver, IEnergyReceiverMK2, IFluidStandardReceiverMK2, IControlReceiver, IGUIProvider { +public class TileEntityFusionPlasmaForge extends TileEntityMachineBase implements IFusionPowerReceiver, IEnergyReceiverMK2, IFluidStandardReceiverMK2, IControlReceiver, IGUIProvider, IRORValueProvider { public FluidTank inputTank; @@ -592,4 +593,25 @@ public class TileEntityFusionPlasmaForge extends TileEntityMachineBase implement double[] newPos = positions[rand.nextInt(positions.length)]; for(int i = 0; i < newPos.length; i++) arm.targetAngles[i] = newPos[i]; } + + @Override + public String[] getFunctionInfo() { + return new String[] { + PREFIX_VALUE + "progress", + PREFIX_VALUE + "recipe", + PREFIX_VALUE + "active", + PREFIX_VALUE + "booster", + PREFIX_VALUE + "plasma", + }; + } + + @Override + public String provideRORValue(String name) { + if((PREFIX_VALUE + "progress").equals(name)) return "" + (int) Math.round(this.plasmaModule.progress * 100); + if((PREFIX_VALUE + "recipe").equals(name)) return this.plasmaModule.getRecipeName(); + if((PREFIX_VALUE + "active").equals(name)) return "" + (this.didProcess ? 1 : 0); + if((PREFIX_VALUE + "booster").equals(name)) return "" + this.booster; + if((PREFIX_VALUE + "plasma").equals(name)) return "" + this.plasmaEnergy; + return null; + } } 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 b278623fe..08992ef16 100644 --- a/src/main/java/com/hbm/tileentity/machine/fusion/TileEntityFusionTorus.java +++ b/src/main/java/com/hbm/tileentity/machine/fusion/TileEntityFusionTorus.java @@ -27,6 +27,7 @@ import com.hbm.util.BobMathUtil; import com.hbm.util.fauxpointtwelve.BlockPos; import com.hbm.util.fauxpointtwelve.DirPos; +import api.hbm.redstoneoverradio.IRORInteractive; import api.hbm.redstoneoverradio.IRORValueProvider; import cpw.mods.fml.common.Optional; import cpw.mods.fml.relauncher.Side; @@ -46,7 +47,7 @@ import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; @Optional.InterfaceList({@Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = "OpenComputers")}) -public class TileEntityFusionTorus extends TileEntityCooledBase implements IGUIProvider, IControlReceiver, SimpleComponent, CompatHandler.OCComponent, IRORValueProvider { +public class TileEntityFusionTorus extends TileEntityCooledBase implements IGUIProvider, IControlReceiver, SimpleComponent, CompatHandler.OCComponent, IRORValueProvider, IRORInteractive { public boolean didProcess = false; @@ -589,7 +590,11 @@ public class TileEntityFusionTorus extends TileEntityCooledBase implements IGUIP public String[] getFunctionInfo() { return new String[] { PREFIX_VALUE + "plasma", - PREFIX_VALUE + "consumption" + PREFIX_VALUE + "consumption", + PREFIX_VALUE + "progress", + PREFIX_VALUE + "recipe", + PREFIX_VALUE + "active", + PREFIX_VALUE + "temp", }; } @@ -597,6 +602,22 @@ public class TileEntityFusionTorus extends TileEntityCooledBase implements IGUIP public String provideRORValue(String name) { if((PREFIX_VALUE + "plasma").equals(name)) return "" + this.plasmaEnergy; if((PREFIX_VALUE + "consumption").equals(name)) return "" + (int) (this.fuelConsumption * 100); + if((PREFIX_VALUE + "progress").equals(name)) return "" + (int) Math.round(this.fusionModule.progress * 100); + if((PREFIX_VALUE + "recipe").equals(name)) return this.fusionModule.getRecipeName(); + if((PREFIX_VALUE + "active").equals(name)) return "" + (this.didProcess ? 1 : 0); + if((PREFIX_VALUE + "temp").equals(name)) return "" + (int) this.temperature; + return null; + } + + @Override + public String runRORFunction(String name, String[] params) { + + if((PREFIX_FUNCTION + "setrecipe").equals(name) && params.length == 1) { + this.fusionModule.setRecipe(params[0], false); + this.markChanged(); + return null; + } + return null; } } diff --git a/src/main/java/com/hbm/tileentity/network/TileEntityFluidCounterValve.java b/src/main/java/com/hbm/tileentity/network/TileEntityFluidCounterValve.java index 285b49ce0..9ccbc2508 100644 --- a/src/main/java/com/hbm/tileentity/network/TileEntityFluidCounterValve.java +++ b/src/main/java/com/hbm/tileentity/network/TileEntityFluidCounterValve.java @@ -140,7 +140,7 @@ public class TileEntityFluidCounterValve extends TileEntityPipeBaseNT implements PREFIX_VALUE + "value", PREFIX_VALUE + "state", PREFIX_FUNCTION + "reset", - PREFIX_FUNCTION + "setState" + NAME_SEPARATOR + "state", + PREFIX_FUNCTION + "setstate" + NAME_SEPARATOR + "state", }; } @@ -149,7 +149,7 @@ public class TileEntityFluidCounterValve extends TileEntityPipeBaseNT implements if(name.equals(PREFIX_FUNCTION + "reset")) { counter = 0; markDirty(); - } else if(name.equals(PREFIX_FUNCTION + "setState")) { + } else if(name.equals(PREFIX_FUNCTION + "setstate")) { setState(IRORInteractive.parseInt(params[0], 0, 1)); } return null; diff --git a/src/main/java/com/hbm/tileentity/network/TileEntityRadioTorchReader.java b/src/main/java/com/hbm/tileentity/network/TileEntityRadioTorchReader.java index 15e0465e9..2a4f9453b 100644 --- a/src/main/java/com/hbm/tileentity/network/TileEntityRadioTorchReader.java +++ b/src/main/java/com/hbm/tileentity/network/TileEntityRadioTorchReader.java @@ -1,5 +1,7 @@ package com.hbm.tileentity.network; +import java.util.Locale; + import com.hbm.interfaces.IControlReceiver; import com.hbm.tileentity.TileEntityLoadedBase; import com.hbm.util.BufferUtil; @@ -44,7 +46,7 @@ public class TileEntityRadioTorchReader extends TileEntityLoadedBase implements if(channel == null || channel.isEmpty()) continue; if(name == null || name.isEmpty()) continue; - String value = prov.provideRORValue(IRORValueProvider.PREFIX_VALUE + name); + String value = prov.provideRORValue(IRORValueProvider.PREFIX_VALUE + name.toLowerCase(Locale.US)); if(value == null) continue; if(polling || !value.equals(previous)) { 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 b639fbb56..8aa8b0df5 100644 --- a/src/main/java/com/hbm/tileentity/network/pneumatic/TileEntityPneumoStorageExporter.java +++ b/src/main/java/com/hbm/tileentity/network/pneumatic/TileEntityPneumoStorageExporter.java @@ -5,12 +5,16 @@ import com.hbm.interfaces.IControlReceiver; import com.hbm.inventory.container.ContainerPneumoStorageExporter; import com.hbm.inventory.gui.GUIPneumoStorageExporter; import com.hbm.tileentity.network.RTTYSystem; +import com.hbm.util.BobMathUtil; +import api.hbm.ntl.StackCache; import api.hbm.ntl.StackCache.CacheSlot; import api.hbm.redstoneoverradio.IRORInteractive; import io.netty.buffer.ByteBuf; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; @@ -24,6 +28,9 @@ public class TileEntityPneumoStorageExporter extends TileEntityPneumaticMachineB public int requestMode = 0; /** Item ID and meta pairs with amount for RoR controlled filters */ public short[][] rorFilters = new short[9][3]; + /** Delay for non-forced (i.e. continuous request) grabs, if not successful */ + public int slotDelay[] = new int[9]; + public static final int SLOT_DELAY = 10; /** 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; @@ -46,16 +53,153 @@ public class TileEntityPneumoStorageExporter extends TileEntityPneumaticMachineB super.updateEntity(); if(!worldObj.isRemote) { + + for(int i = 0; i < 9; i++) { + if(slotDelay[i] > 0) slotDelay[i]--; + } + + if(continuousRequest) { + this.doRequest(false); + } + this.networkPackNT(15); } } public void doRequest(boolean force) { + if(this.requestMode != MODE_FULL_REQUEST) { + // handle all filters individually + for(int i = 0; i < 9; i++) if(!requestSlot(i, force)) this.slotDelay[i] = SLOT_DELAY; + } else { + + // check filter delay if forced pulls aren't active + if(!force) for(int i = 0; i < 9; i++) { + short[] filter = this.getFilter(i); + if(filter != null && slotDelay[i] > 0) return; + } + + // check if filter demands are met and space is free + for(int i = 0; i < 9; i++) { + short[] filter = this.getFilter(i); + if(filter == null) continue; + + int itemId = filter[0]; + Item item = Item.getItemById(itemId); + int meta = filter[1]; + int requestSize = filter[2]; + + int existingSize = 0; + ItemStack existingStack = slots[i]; + + if(existingStack != null) { + if(existingStack.getItem() == item && existingStack.getItemDamage() == meta && !existingStack.hasTagCompound()) { + existingSize = existingStack.stackSize; + } else { + this.slotDelay[i] = SLOT_DELAY; + return; + } + } + + ItemStack newStack = new ItemStack(item, 1, meta); + int capacityLeft = newStack.getMaxStackSize() - existingSize; + + if(capacityLeft < requestSize || getAvailability(itemId, meta) < requestSize) { + this.slotDelay[i] = SLOT_DELAY; + return; + } + } + + // everything is good, pull items. continues should not happen, but are in place nonetheless + for(int i = 0; i < 9; i++) { + short[] filter = this.getFilter(i); + if(filter == null) continue; + + int itemId = filter[0]; + Item item = Item.getItemById(itemId); + int meta = filter[1]; + int requestSize = filter[2]; + + int existingSize = 0; + ItemStack existingStack = slots[i]; + if(existingStack != null) existingSize = existingStack.stackSize; + + ItemStack newStack = new ItemStack(item, 1, meta); + + long hash = StackCache.getStackIdentity(itemId, meta, null); + if(hash == this.cache.getNullIdentity()) continue; // safeguard + + CacheSlot cacheSlot = this.cache.cacheSlots.get(hash); + if(cacheSlot == null) continue; // safeguard + + slots[i] = newStack; + slots[i].stackSize = existingSize + (int) this.cache.consumeItemsAndReturnQuantity(newStack, requestSize); + } + + this.markChanged(); + } } - public void requestSlot(int slot, boolean force) { + /** Returns false if the slot delay should be reset (unsuccessful) or true of not (successful or delay still active) */ + public boolean requestSlot(int slot, boolean force) { + if(!force && slotDelay[slot] > 0) return true; + if(this.cache == null || this.cache.hasExpired) return false; + + short[] filter = this.getFilter(slot); + if(filter == null) return false; + + int itemId = filter[0]; + Item item = Item.getItemById(itemId); + int meta = filter[1]; + int requestSize = filter[2]; + + int existingSize = 0; + ItemStack existingStack = slots[slot]; + + if(existingStack != null) { + if(existingStack.getItem() == item && existingStack.getItemDamage() == meta && !existingStack.hasTagCompound()) { + existingSize = existingStack.stackSize; + } else { + return false; + } + } + + ItemStack newStack = new ItemStack(item, 1, meta); + int capacityLeft = newStack.getMaxStackSize() - existingSize; + + // any non-AMAP mode will fail if it can't insert that much before we even check availability from the pneumo sys + if(capacityLeft < requestSize && this.requestMode != MODE_AS_MUCH_AS_POSSIBLE) return false; + long hash = StackCache.getStackIdentity(itemId, meta, null); + if(hash == this.cache.getNullIdentity()) return false; + + CacheSlot cacheSlot = this.cache.cacheSlots.get(hash); + if(cacheSlot == null) return false; + + // any non-AMAP mode will fail if the system doesn't have the requested amount + if(cacheSlot.stacksize < requestSize && this.requestMode != MODE_AS_MUCH_AS_POSSIBLE) return false; + if(cacheSlot.stacksize <= 0) return false; + + int toPull = (int) BobMathUtil.min(requestSize, cacheSlot.stacksize, capacityLeft); + slots[slot] = newStack; + slots[slot].stackSize = existingSize + (int) this.cache.consumeItemsAndReturnQuantity(newStack, toPull); + this.markChanged(); + + return true; + } + + /** Returns item id, meta and request size for the given filter. Returns null if no filter is specified */ + public short[] getFilter(int slot) { + if(rorConfiguredMode) { + if(Item.getItemById(rorFilters[slot][0]) == null) return null; + return rorFilters[slot]; + } else { + if(slots[slot] != null) { + ItemStack stack = slots[slot]; + return new short[] {(short) Item.getIdFromItem(stack.getItem()), (short) stack.getItemDamage(), (short) stack.stackSize}; + } + return null; + } } public long getAvailability(int item, int meta) { @@ -127,7 +271,7 @@ public class TileEntityPneumoStorageExporter extends TileEntityPneumaticMachineB @Override public String runRORFunction(String name, String[] params) { - if("setfilter".equals(name) && params.length == 4) { + if((PREFIX_FUNCTION + "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); @@ -140,25 +284,25 @@ public class TileEntityPneumoStorageExporter extends TileEntityPneumaticMachineB return null; } - if("setcontinuous".equals(name) && params.length == 1) { + if((PREFIX_FUNCTION + "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)) { + if((PREFIX_FUNCTION + "request").equals(name)) { this.doRequest(true); return null; } - if("requestslot".equals(name) && params.length == 1) { + if((PREFIX_FUNCTION + "requestslot").equals(name) && params.length == 1) { int slot = IRORInteractive.parseInt(params[0], 1, 9) - 1; - this.requestSlot(slot, true); + if(!this.requestSlot(slot, true)) this.slotDelay[slot] = SLOT_DELAY; return null; } - if("checkavailability".equals(name) && params.length == 3) { + if((PREFIX_FUNCTION + "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]; diff --git a/src/main/java/com/hbm/tileentity/turret/TileEntityTurretBaseArtillery.java b/src/main/java/com/hbm/tileentity/turret/TileEntityTurretBaseArtillery.java index e971b8e6f..863f298e7 100644 --- a/src/main/java/com/hbm/tileentity/turret/TileEntityTurretBaseArtillery.java +++ b/src/main/java/com/hbm/tileentity/turret/TileEntityTurretBaseArtillery.java @@ -96,13 +96,13 @@ public abstract class TileEntityTurretBaseArtillery extends TileEntityTurretBase @Override public String[] getFunctionInfo() { return new String[] { - PREFIX_FUNCTION + "setActive" + NAME_SEPARATOR + "active (0 or 1)", - PREFIX_FUNCTION + "targetPlayers" + NAME_SEPARATOR + "enabled (0 or 1)", - PREFIX_FUNCTION + "targetAnimals" + NAME_SEPARATOR + "enabled (0 or 1)", - PREFIX_FUNCTION + "targetMobs" + NAME_SEPARATOR + "enabled (0 or 1)", - PREFIX_FUNCTION + "targetMachines" + NAME_SEPARATOR + "enabled (0 or 1)", - PREFIX_FUNCTION + "addWhitelist" + NAME_SEPARATOR + "name", - PREFIX_FUNCTION + "removeWhitelist" + NAME_SEPARATOR + "name", + PREFIX_FUNCTION + "setactive" + NAME_SEPARATOR + "active (0 or 1)", + PREFIX_FUNCTION + "targetplayers" + NAME_SEPARATOR + "enabled (0 or 1)", + PREFIX_FUNCTION + "targetanimals" + NAME_SEPARATOR + "enabled (0 or 1)", + PREFIX_FUNCTION + "targetmobs" + NAME_SEPARATOR + "enabled (0 or 1)", + PREFIX_FUNCTION + "targetmachines" + NAME_SEPARATOR + "enabled (0 or 1)", + PREFIX_FUNCTION + "addwhitelist" + NAME_SEPARATOR + "name", + PREFIX_FUNCTION + "removewhitelist" + NAME_SEPARATOR + "name", PREFIX_FUNCTION + "enqueue" + NAME_SEPARATOR + "x" + PARAM_SEPARATOR + "y" + PARAM_SEPARATOR + "z", }; } diff --git a/src/main/java/com/hbm/tileentity/turret/TileEntityTurretBaseNT.java b/src/main/java/com/hbm/tileentity/turret/TileEntityTurretBaseNT.java index 1d75b1679..c9e5e2c8c 100644 --- a/src/main/java/com/hbm/tileentity/turret/TileEntityTurretBaseNT.java +++ b/src/main/java/com/hbm/tileentity/turret/TileEntityTurretBaseNT.java @@ -1062,40 +1062,40 @@ public abstract class TileEntityTurretBaseNT extends TileEntityMachineBase imple @Override public String[] getFunctionInfo() { return new String[] { - PREFIX_FUNCTION + "setActive" + NAME_SEPARATOR + "active (0 or 1)", - PREFIX_FUNCTION + "targetPlayers" + NAME_SEPARATOR + "enabled (0 or 1)", - PREFIX_FUNCTION + "targetAnimals" + NAME_SEPARATOR + "enabled (0 or 1)", - PREFIX_FUNCTION + "targetMobs" + NAME_SEPARATOR + "enabled (0 or 1)", - PREFIX_FUNCTION + "targetMachines" + NAME_SEPARATOR + "enabled (0 or 1)", - PREFIX_FUNCTION + "addWhitelist" + NAME_SEPARATOR + "name", - PREFIX_FUNCTION + "removeWhitelist" + NAME_SEPARATOR + "name", + PREFIX_FUNCTION + "setactive" + NAME_SEPARATOR + "active (0 or 1)", + PREFIX_FUNCTION + "targetplayers" + NAME_SEPARATOR + "enabled (0 or 1)", + PREFIX_FUNCTION + "targetanimals" + NAME_SEPARATOR + "enabled (0 or 1)", + PREFIX_FUNCTION + "targetmobs" + NAME_SEPARATOR + "enabled (0 or 1)", + PREFIX_FUNCTION + "targetmachines" + NAME_SEPARATOR + "enabled (0 or 1)", + PREFIX_FUNCTION + "addwhitelist" + NAME_SEPARATOR + "name", + PREFIX_FUNCTION + "removewhitelist" + NAME_SEPARATOR + "name", }; } @Override public String runRORFunction(String name, String[] params) { - if((PREFIX_FUNCTION + "setActive").equals(name) && params.length > 0) { + if((PREFIX_FUNCTION + "setactive").equals(name) && params.length > 0) { try { this.isOn = (Integer.parseInt(params[0]) == 1); this.markChanged(); } catch(NumberFormatException e) {} } - if((PREFIX_FUNCTION + "targetPlayers").equals(name) && params.length > 0) { + if((PREFIX_FUNCTION + "targetplayers").equals(name) && params.length > 0) { try { this.targetPlayers = (Integer.parseInt(params[0]) == 1); this.markChanged(); } catch(NumberFormatException e) {} } - if((PREFIX_FUNCTION + "targetAnimals").equals(name) && params.length > 0) { + if((PREFIX_FUNCTION + "targetanimals").equals(name) && params.length > 0) { try { this.targetAnimals = (Integer.parseInt(params[0]) == 1); this.markChanged(); } catch(NumberFormatException e) {} } - if((PREFIX_FUNCTION + "targetMobs").equals(name) && params.length > 0) { + if((PREFIX_FUNCTION + "targetmobs").equals(name) && params.length > 0) { try { this.targetMobs = (Integer.parseInt(params[0]) == 1); this.markChanged(); } catch(NumberFormatException e) {} } - if((PREFIX_FUNCTION + "targetMachines").equals(name) && params.length > 0) { + if((PREFIX_FUNCTION + "targetmachines").equals(name) && params.length > 0) { try { this.targetMachines = (Integer.parseInt(params[0]) == 1); this.markChanged(); } catch(NumberFormatException e) {} } - if((PREFIX_FUNCTION + "addWhitelist").equals(name) && params.length > 0) { + if((PREFIX_FUNCTION + "addwhitelist").equals(name) && params.length > 0) { String playerName = params[0]; List whitelist = this.getWhitelist(); if(!whitelist.contains(playerName)) this.addName(playerName); this.markChanged(); } - if((PREFIX_FUNCTION + "removeWhitelist").equals(name) && params.length > 0) { + if((PREFIX_FUNCTION + "removewhitelist").equals(name) && params.length > 0) { String playerName = params[0]; List whitelist = this.getWhitelist(); if(whitelist.contains(playerName)) this.removeName(whitelist.indexOf(playerName)); diff --git a/src/main/resources/assets/hbm/textures/gui/machine/gui_rtty_autocal.png b/src/main/resources/assets/hbm/textures/gui/machine/gui_rtty_autocal.png index 9f4121524..cb5fa04e3 100644 Binary files a/src/main/resources/assets/hbm/textures/gui/machine/gui_rtty_autocal.png and b/src/main/resources/assets/hbm/textures/gui/machine/gui_rtty_autocal.png differ diff --git a/src/main/resources/assets/hbm/textures/items/plate_dura_steel.png b/src/main/resources/assets/hbm/textures/items/plate_dura_steel.png index a33109caf..68b0b8330 100644 Binary files a/src/main/resources/assets/hbm/textures/items/plate_dura_steel.png and b/src/main/resources/assets/hbm/textures/items/plate_dura_steel.png differ