diff --git a/dependencies.gradle b/dependencies.gradle index 5df5ab0f9..603b81a68 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -67,8 +67,9 @@ final def mod_dependencies = [ 'extrabotany-299086:3112313' : [project.debug_extra_botany], 'extra-utilities-2-225561:2678374' : [project.debug_extra_utilities_2], 'forestry-59751:2918418' : [project.debug_forestry], - 'immersive_engineering-231951:2974106' : [project.debug_immersive_engineering, project.debug_immersive_petroleum], + 'immersive_engineering-231951:2974106' : [project.debug_immersive_engineering, project.debug_immersive_petroleum, project.debug_immersive_technology], 'immersive-petroleum-268250:3382321' : [project.debug_immersive_petroleum], + 'mct-immersive-technology-359407:5108047' : [project.debug_immersive_technology], // WARNING: experimental must be placed before classic, otherwise you will crash when debugging either. Check FluidGenerator compat to confirm 'industrialcraft_experimental-242638:3838713' : [project.debug_industrial_craft_2_experimental], 'industrialcraft_classic-242942:3093607' : [project.debug_industrial_craft_2_classic], diff --git a/examples/postInit/immersivetech.groovy b/examples/postInit/immersivetech.groovy new file mode 100644 index 000000000..e67f4644a --- /dev/null +++ b/examples/postInit/immersivetech.groovy @@ -0,0 +1,263 @@ + +// Auto generated groovyscript example file +// MODS_LOADED: immersivetech + +println 'mod \'immersivetech\' detected, running script' + +// Boiler: +// Converts an input fluidstack into an output fluidstack after a given amount of time in a multiblock structure when the +// multiblock has had its heat value increased enough by fuel. + +mods.immersivetech.boiler.removeByInput(fluid('water')) +mods.immersivetech.boiler.removeByOutput(fluid('steam')) +// mods.immersivetech.boiler.removeAll() + +mods.immersivetech.boiler.recipeBuilder() + .fluidInput(fluid('lava') * 100) + .fluidOutput(fluid('hot_spring_water') * 500) + .time(100) + .register() + +mods.immersivetech.boiler.recipeBuilder() + .fluidInput(fluid('water') * 50) + .fluidOutput(fluid('lava') * 50) + .time(50) + .register() + + +// Boiler Fuel: +// Converts an input fluidstack into heat for the Boiler multiblock structure over a given amount of time. + +mods.immersivetech.boiler_fuel.removeByInput(fluid('biodiesel')) +// mods.immersivetech.boiler_fuel.removeAll() + +mods.immersivetech.boiler_fuel.recipeBuilder() + .fluidInput(fluid('lava') * 100) + .time(100) + .heat(10) + .register() + +mods.immersivetech.boiler_fuel.recipeBuilder() + .fluidInput(fluid('water') * 50) + .time(50) + .heat(0.05) + .register() + + +// Cooling Tower: +// Converts up to two input fluidstacks into up to three output fluidstacks after a given amount of time in a multiblock +// structure. + +mods.immersivetech.cooling_tower.removeByInput(fluid('hot_spring_water')) +// mods.immersivetech.cooling_tower.removeByOutput(fluid('water')) +// mods.immersivetech.cooling_tower.removeAll() + +mods.immersivetech.cooling_tower.recipeBuilder() + .fluidInput(fluid('lava') * 100) + .fluidOutput(fluid('hot_spring_water') * 500) + .time(100) + .register() + +mods.immersivetech.cooling_tower.recipeBuilder() + .fluidInput(fluid('water') * 50, fluid('hot_spring_water') * 50) + .fluidOutput(fluid('lava') * 50, fluid('water') * 50, fluid('lava') * 50) + .time(50) + .register() + + +// Distiller: +// Converts an input fluidstack into an output fluidstack and has a chance to output an itemstack after a given amount of +// time in a multiblock structure. + +// mods.immersivetech.distiller.removeByInput(fluid('water')) +mods.immersivetech.distiller.removeByOutput(fluid('distwater')) +// mods.immersivetech.distiller.removeByOutput(item('immersivetech:material')) +// mods.immersivetech.distiller.removeAll() + +mods.immersivetech.distiller.recipeBuilder() + .fluidInput(fluid('lava') * 100) + .fluidOutput(fluid('hot_spring_water') * 500) + .time(100) + .register() + +mods.immersivetech.distiller.recipeBuilder() + .fluidInput(fluid('water') * 50) + .fluidOutput(fluid('lava') * 50) + .output(item('minecraft:diamond')) + .chance(0.5f) + .time(50) + .energy(5000) + .register() + + +// Electrolytic Crucible Battery: +// Converts an input fluidstack into up to three output fluidstacks after a given amount of time and energy in a multiblock +// structure. + +mods.immersivetech.electrolytic_crucible_battery.removeByInput(fluid('moltensalt')) +// mods.immersivetech.electrolytic_crucible_battery.removeByOutput(fluid('chlorine')) +// mods.immersivetech.electrolytic_crucible_battery.removeAll() + +mods.immersivetech.electrolytic_crucible_battery.recipeBuilder() + .fluidInput(fluid('lava') * 100) + .fluidOutput(fluid('hot_spring_water') * 500) + .output(item('minecraft:clay')) + .time(100) + .register() + +mods.immersivetech.electrolytic_crucible_battery.recipeBuilder() + .fluidInput(fluid('water') * 500) + .fluidOutput(fluid('lava') * 50, fluid('hot_spring_water') * 50, fluid('water') * 400) + .output(item('minecraft:diamond')) + .time(50) + .energy(5000) + .register() + + +// Gas Turbine: +// Converts an input fluidstack into an output fluidstack after a given amount of time in a multiblock structure, producing +// power for an adjacent Alternator multiblock. + +mods.immersivetech.gas_turbine.removeByInput(fluid('biodiesel')) +// mods.immersivetech.gas_turbine.removeByOutput(fluid('fluegas')) +// mods.immersivetech.gas_turbine.removeAll() + +mods.immersivetech.gas_turbine.recipeBuilder() + .fluidInput(fluid('lava') * 100) + .fluidOutput(fluid('hot_spring_water') * 500) + .time(100) + .register() + +mods.immersivetech.gas_turbine.recipeBuilder() + .fluidInput(fluid('water') * 50) + .fluidOutput(fluid('lava') * 50) + .time(50) + .register() + + +// Heat Exchanger: +// Converts up to two input fluidstacks into up to two output fluidstacks after a given amount of time in a multiblock +// structure. + +mods.immersivetech.heat_exchanger.removeByInput(fluid('fluegas')) +mods.immersivetech.heat_exchanger.removeByOutput(fluid('hot_spring_water')) +// mods.immersivetech.heat_exchanger.removeAll() + +mods.immersivetech.heat_exchanger.recipeBuilder() + .fluidInput(fluid('lava') * 100, fluid('lava') * 50) + .fluidOutput(fluid('hot_spring_water') * 500) + .time(100) + .register() + +mods.immersivetech.heat_exchanger.recipeBuilder() + .fluidInput(fluid('water') * 50, fluid('hot_spring_water') * 50) + .fluidOutput(fluid('lava') * 50, fluid('water') * 10) + .time(50) + .energy(5000) + .register() + + +// High-Pressure Steam Turbine: +// Converts an input fluidstack into an output fluidstack after a given amount of time in a multiblock structure, producing +// power for an adjacent Alternator multiblock. + +mods.immersivetech.high_pressure_steam_turbine.removeByInput(fluid('highpressuresteam')) +// mods.immersivetech.high_pressure_steam_turbine.removeByOutput(fluid('steam')) +// mods.immersivetech.high_pressure_steam_turbine.removeAll() + +mods.immersivetech.high_pressure_steam_turbine.recipeBuilder() + .fluidInput(fluid('lava') * 100) + .fluidOutput(fluid('hot_spring_water') * 500) + .time(100) + .register() + +mods.immersivetech.high_pressure_steam_turbine.recipeBuilder() + .fluidInput(fluid('water') * 50) + .fluidOutput(fluid('lava') * 50) + .time(50) + .register() + + +// Melting Crucible: +// Converts an input itemstack into an output fluidstack after a given amount of time and energy in a multiblock structure. + +mods.immersivetech.melting_crucible.removeByInput(item('minecraft:cobblestone')) +mods.immersivetech.melting_crucible.removeByOutput(fluid('moltensalt')) +// mods.immersivetech.melting_crucible.removeAll() + +mods.immersivetech.melting_crucible.recipeBuilder() + .input(item('minecraft:diamond')) + .fluidOutput(fluid('hot_spring_water')) + .time(100) + .register() + +mods.immersivetech.melting_crucible.recipeBuilder() + .input(item('minecraft:clay') * 8) + .fluidOutput(fluid('lava') * 50) + .time(50) + .energy(5000) + .register() + + +// Radiator: +// Converts an input fluidstack into an output fluidstack after a given amount of time in a multiblock structure. + +mods.immersivetech.radiator.removeByInput(fluid('exhauststeam')) +// mods.immersivetech.radiator.removeByOutput(fluid('distwater')) +// mods.immersivetech.radiator.removeAll() + +mods.immersivetech.radiator.recipeBuilder() + .fluidInput(fluid('lava') * 100) + .fluidOutput(fluid('hot_spring_water') * 500) + .time(100) + .register() + +mods.immersivetech.radiator.recipeBuilder() + .fluidInput(fluid('water') * 50) + .fluidOutput(fluid('lava') * 50) + .time(50) + .register() + + +// Solar Tower: +// Converts an input fluidstack into an output fluidstack after a given amount of time in a multiblock structure, with the +// time being able to be sped up via Solar Reflector multiblocks. + +mods.immersivetech.solar_tower.removeByInput(fluid('water')) +mods.immersivetech.solar_tower.removeByOutput(fluid('superheatedmoltensodium')) +// mods.immersivetech.solar_tower.removeAll() + +mods.immersivetech.solar_tower.recipeBuilder() + .fluidInput(fluid('lava') * 100) + .fluidOutput(fluid('hot_spring_water') * 500) + .time(100) + .register() + +mods.immersivetech.solar_tower.recipeBuilder() + .fluidInput(fluid('water') * 50) + .fluidOutput(fluid('lava') * 50) + .time(50) + .register() + + +// Steam Turbine: +// Converts an input fluidstack into an output fluidstack after a given amount of time in a multiblock structure, producing +// power for an adjacent Alternator multiblock. + +mods.immersivetech.steam_turbine.removeByInput(fluid('steam')) +// mods.immersivetech.steam_turbine.removeByOutput(fluid('exhauststeam')) +// mods.immersivetech.steam_turbine.removeAll() + +mods.immersivetech.steam_turbine.recipeBuilder() + .fluidInput(fluid('lava') * 100) + .fluidOutput(fluid('hot_spring_water') * 500) + .time(100) + .register() + +mods.immersivetech.steam_turbine.recipeBuilder() + .fluidInput(fluid('water') * 50) + .fluidOutput(fluid('lava') * 50) + .time(50) + .register() + + diff --git a/gradle.properties b/gradle.properties index 2ce2f3679..d241de0e4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,8 +4,8 @@ debug_run_ls = false debug_use_examples_folder = true debug_log_missing_lang_keys = true -debug_generate_examples = false -debug_generate_wiki = false +debug_generate_examples = true +debug_generate_wiki = true debug_generate_and_crash = false # END SECTION: development environment settings @@ -40,6 +40,7 @@ debug_extra_utilities_2 = false debug_forestry = false debug_immersive_engineering = false debug_immersive_petroleum = false +debug_immersive_technology = true debug_industrial_craft_2_classic = false debug_industrial_craft_2_experimental = false debug_industrial_foregoing = false diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ModSupport.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ModSupport.java index 6b16cd3fc..408e3d807 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ModSupport.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ModSupport.java @@ -32,6 +32,7 @@ import com.cleanroommc.groovyscript.compat.mods.ic2.IC2; import com.cleanroommc.groovyscript.compat.mods.immersiveengineering.ImmersiveEngineering; import com.cleanroommc.groovyscript.compat.mods.immersivepetroleum.ImmersivePetroleum; +import com.cleanroommc.groovyscript.compat.mods.immersivetechnology.ImmersiveTechnology; import com.cleanroommc.groovyscript.compat.mods.industrialforegoing.IndustrialForegoing; import com.cleanroommc.groovyscript.compat.mods.inspirations.Inspirations; import com.cleanroommc.groovyscript.compat.mods.integrateddynamics.IntegratedDynamics; @@ -101,6 +102,7 @@ public class ModSupport { public static final GroovyContainer FORESTRY = new InternalModContainer<>("forestry", "Forestry", Forestry::new); public static final GroovyContainer IMMERSIVE_ENGINEERING = new InternalModContainer<>("immersiveengineering", "Immersive Engineering", ImmersiveEngineering::new, "ie"); public static final GroovyContainer IMMERSIVE_PETROLEUM = new InternalModContainer<>("immersivepetroleum", "Immersive Petroleum", ImmersivePetroleum::new); + public static final GroovyContainer IMMERSIVE_TECHNOLOGY = new InternalModContainer<>("immersivetech", "Immersive Technology", ImmersiveTechnology::new); public static final GroovyContainer INDUSTRIALCRAFT = new InternalModContainer<>("ic2", "Industrial Craft 2", IC2::new, "industrialcraft"); public static final GroovyContainer INDUSTRIAL_FOREGOING = new InternalModContainer<>("industrialforegoing", "Industrial Foregoing", IndustrialForegoing::new); public static final GroovyContainer INSPIRATIONS = new InternalModContainer<>("inspirations", "Inspirations", Inspirations::new); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/Boiler.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/Boiler.java new file mode 100644 index 000000000..081d129bb --- /dev/null +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/Boiler.java @@ -0,0 +1,128 @@ +package com.cleanroommc.groovyscript.compat.mods.immersivetechnology; + +import com.cleanroommc.groovyscript.api.GroovyBlacklist; +import com.cleanroommc.groovyscript.api.GroovyLog; +import com.cleanroommc.groovyscript.api.IIngredient; +import com.cleanroommc.groovyscript.api.documentation.annotations.*; +import com.cleanroommc.groovyscript.compat.mods.ModSupport; +import com.cleanroommc.groovyscript.helper.SimpleObjectStream; +import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; +import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import mctmods.immersivetechnology.api.crafting.BoilerRecipe; +import mctmods.immersivetechnology.common.Config; +import net.minecraftforge.fluids.FluidStack; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + +@RegistryDescription +public class Boiler extends VirtualizedRegistry { + + @Override + public boolean isEnabled() { + return Config.ITConfig.Machines.Multiblock.enable_boiler; + } + + @RecipeBuilderDescription(example = { + @Example(".fluidInput(fluid('lava') * 100).fluidOutput(fluid('hot_spring_water') * 500).time(100)"), + @Example(".fluidInput(fluid('water') * 50).fluidOutput(fluid('lava') * 50).time(50)") + }) + public RecipeBuilder recipeBuilder() { + return new RecipeBuilder(); + } + + @Override + @GroovyBlacklist + @ApiStatus.Internal + public void onReload() { + BoilerRecipe.recipeList.removeAll(removeScripted()); + BoilerRecipe.recipeList.addAll(restoreFromBackup()); + } + + public void add(BoilerRecipe recipe) { + if (recipe != null) { + addScripted(recipe); + BoilerRecipe.recipeList.add(recipe); + } + } + + public boolean remove(BoilerRecipe recipe) { + if (BoilerRecipe.recipeList.removeIf(r -> r == recipe)) { + addBackup(recipe); + return true; + } + return false; + } + + @MethodDescription(example = @Example("fluid('water')")) + public void removeByInput(IIngredient input) { + BoilerRecipe.recipeList.removeIf(r -> { + for (FluidStack fluidStack : r.getFluidInputs()) { + if (input.test(fluidStack)) { + addBackup(r); + return true; + } + } + return false; + }); + } + + @MethodDescription(example = @Example("fluid('steam')")) + public void removeByOutput(IIngredient output) { + BoilerRecipe.recipeList.removeIf(r -> { + for (FluidStack fluidStack : r.getFluidOutputs()) { + if (output.test(fluidStack)) { + addBackup(r); + return true; + } + } + return false; + }); + } + + @MethodDescription(type = MethodDescription.Type.QUERY) + public SimpleObjectStream streamRecipes() { + return new SimpleObjectStream<>(BoilerRecipe.recipeList).setRemover(this::remove); + } + + @MethodDescription(priority = 2000, example = @Example(commented = true)) + public void removeAll() { + BoilerRecipe.recipeList.forEach(this::addBackup); + BoilerRecipe.recipeList.clear(); + } + + @Property(property = "fluidInput", valid = @Comp("1")) + @Property(property = "fluidOutput", valid = @Comp("1")) + public static class RecipeBuilder extends AbstractRecipeBuilder { + + @Property(valid = @Comp(value = "0", type = Comp.Type.GTE)) + private int time; + + @RecipeBuilderMethodDescription + public RecipeBuilder time(int time) { + this.time = time; + return this; + } + + @Override + public String getErrorMsg() { + return "Error adding Immersive Technology Boiler recipe"; + } + + @Override + public void validate(GroovyLog.Msg msg) { + validateItems(msg); + validateFluids(msg, 1, 1, 1, 1); + msg.add(time <= 0, "time must be greater than or equal to 1, yet it was {}", time); + } + + @Override + @RecipeBuilderRegistrationMethod + public @Nullable BoilerRecipe register() { + if (!validate()) return null; + BoilerRecipe recipe = new BoilerRecipe(fluidOutput.get(0), fluidInput.get(0), time); + ModSupport.IMMERSIVE_TECHNOLOGY.get().boiler.add(recipe); + return recipe; + } + } + +} diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/BoilerFuel.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/BoilerFuel.java new file mode 100644 index 000000000..f2c3fa587 --- /dev/null +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/BoilerFuel.java @@ -0,0 +1,124 @@ +package com.cleanroommc.groovyscript.compat.mods.immersivetechnology; + +import com.cleanroommc.groovyscript.api.GroovyBlacklist; +import com.cleanroommc.groovyscript.api.GroovyLog; +import com.cleanroommc.groovyscript.api.IIngredient; +import com.cleanroommc.groovyscript.api.documentation.annotations.*; +import com.cleanroommc.groovyscript.compat.mods.ModSupport; +import com.cleanroommc.groovyscript.helper.SimpleObjectStream; +import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; +import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import mctmods.immersivetechnology.api.crafting.BoilerRecipe; +import mctmods.immersivetechnology.common.Config; +import net.minecraftforge.fluids.FluidStack; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + +@RegistryDescription(category = RegistryDescription.Category.ENTRIES) +public class BoilerFuel extends VirtualizedRegistry { + + @Override + public boolean isEnabled() { + return Config.ITConfig.Machines.Multiblock.enable_boiler; + } + + @RecipeBuilderDescription(example = { + @Example(".fluidInput(fluid('lava') * 100).time(100).heat(10)"), + @Example(".fluidInput(fluid('water') * 50).time(50).heat(0.05)") + }) + public RecipeBuilder recipeBuilder() { + return new RecipeBuilder(); + } + + @Override + @GroovyBlacklist + @ApiStatus.Internal + public void onReload() { + BoilerRecipe.fuelList.removeAll(removeScripted()); + BoilerRecipe.fuelList.addAll(restoreFromBackup()); + } + + public void add(BoilerRecipe.BoilerFuelRecipe recipe) { + if (recipe != null) { + addScripted(recipe); + BoilerRecipe.fuelList.add(recipe); + } + } + + public boolean remove(BoilerRecipe.BoilerFuelRecipe recipe) { + if (BoilerRecipe.fuelList.removeIf(r -> r == recipe)) { + addBackup(recipe); + return true; + } + return false; + } + + @MethodDescription(example = @Example("fluid('biodiesel')")) + public void removeByInput(IIngredient input) { + BoilerRecipe.fuelList.removeIf(r -> { + for (FluidStack fluidStack : r.getFluidInputs()) { + if (input.test(fluidStack)) { + addBackup(r); + return true; + } + } + return false; + }); + } + + @MethodDescription(type = MethodDescription.Type.QUERY) + public SimpleObjectStream streamRecipes() { + return new SimpleObjectStream<>(BoilerRecipe.fuelList).setRemover(this::remove); + } + + @MethodDescription(priority = 2000, example = @Example(commented = true)) + public void removeAll() { + BoilerRecipe.fuelList.forEach(this::addBackup); + BoilerRecipe.fuelList.clear(); + } + + @Property(property = "fluidInput", valid = @Comp("1")) + public static class RecipeBuilder extends AbstractRecipeBuilder { + + @Property(valid = @Comp(value = "0", type = Comp.Type.GTE)) + private int time; + @Property(valid = @Comp(value = "0", type = Comp.Type.GTE)) + private double heat; + + @RecipeBuilderMethodDescription + public RecipeBuilder time(int time) { + this.time = time; + return this; + } + + @RecipeBuilderMethodDescription + public RecipeBuilder heat(double heat) { + this.heat = heat; + return this; + } + + @Override + public String getErrorMsg() { + return "Error adding Immersive Technology Boiler Fuel entry"; + } + + @Override + public void validate(GroovyLog.Msg msg) { + validateItems(msg); + validateFluids(msg, 1, 1, 0, 0); + msg.add(time <= 0, "time must be greater than or equal to 1, yet it was {}", time); + msg.add(heat <= 0, "heat must be greater than or equal to 1, yet it was {}", heat); + } + + @Override + @RecipeBuilderRegistrationMethod + public @Nullable BoilerRecipe.BoilerFuelRecipe register() { + if (!validate()) return null; + BoilerRecipe.BoilerFuelRecipe recipe = new BoilerRecipe.BoilerFuelRecipe(fluidInput.get(0), time, heat); + ModSupport.IMMERSIVE_TECHNOLOGY.get().boilerFuel.add(recipe); + return recipe; + } + + } + +} diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/CoolingTower.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/CoolingTower.java new file mode 100644 index 000000000..6aa97fa56 --- /dev/null +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/CoolingTower.java @@ -0,0 +1,128 @@ +package com.cleanroommc.groovyscript.compat.mods.immersivetechnology; + +import com.cleanroommc.groovyscript.api.GroovyBlacklist; +import com.cleanroommc.groovyscript.api.GroovyLog; +import com.cleanroommc.groovyscript.api.IIngredient; +import com.cleanroommc.groovyscript.api.documentation.annotations.*; +import com.cleanroommc.groovyscript.compat.mods.ModSupport; +import com.cleanroommc.groovyscript.helper.SimpleObjectStream; +import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; +import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import mctmods.immersivetechnology.api.crafting.CoolingTowerRecipe; +import mctmods.immersivetechnology.common.Config; +import net.minecraftforge.fluids.FluidStack; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + +@RegistryDescription +public class CoolingTower extends VirtualizedRegistry { + + @Override + public boolean isEnabled() { + return Config.ITConfig.Machines.Multiblock.enable_coolingTower; + } + + @RecipeBuilderDescription(example = { + @Example(".fluidInput(fluid('lava') * 100).fluidOutput(fluid('hot_spring_water') * 500).time(100)"), + @Example(".fluidInput(fluid('water') * 50, fluid('hot_spring_water') * 50).fluidOutput(fluid('lava') * 50, fluid('water') * 50, fluid('lava') * 50).time(50)") + }) + public RecipeBuilder recipeBuilder() { + return new RecipeBuilder(); + } + + @Override + @GroovyBlacklist + @ApiStatus.Internal + public void onReload() { + CoolingTowerRecipe.recipeList.removeAll(removeScripted()); + CoolingTowerRecipe.recipeList.addAll(restoreFromBackup()); + } + + public void add(CoolingTowerRecipe recipe) { + if (recipe != null) { + addScripted(recipe); + CoolingTowerRecipe.recipeList.add(recipe); + } + } + + public boolean remove(CoolingTowerRecipe recipe) { + if (CoolingTowerRecipe.recipeList.removeIf(r -> r == recipe)) { + addBackup(recipe); + return true; + } + return false; + } + + @MethodDescription(example = @Example("fluid('hot_spring_water')")) + public void removeByInput(IIngredient input) { + CoolingTowerRecipe.recipeList.removeIf(r -> { + for (FluidStack fluidStack : r.getFluidInputs()) { + if (input.test(fluidStack)) { + addBackup(r); + return true; + } + } + return false; + }); + } + + @MethodDescription(example = @Example(value = "fluid('water')", commented = true)) + public void removeByOutput(IIngredient output) { + CoolingTowerRecipe.recipeList.removeIf(r -> { + for (FluidStack fluidStack : r.getFluidOutputs()) { + if (output.test(fluidStack)) { + addBackup(r); + return true; + } + } + return false; + }); + } + + @MethodDescription(type = MethodDescription.Type.QUERY) + public SimpleObjectStream streamRecipes() { + return new SimpleObjectStream<>(CoolingTowerRecipe.recipeList).setRemover(this::remove); + } + + @MethodDescription(priority = 2000, example = @Example(commented = true)) + public void removeAll() { + CoolingTowerRecipe.recipeList.forEach(this::addBackup); + CoolingTowerRecipe.recipeList.clear(); + } + + @Property(property = "fluidInput", valid = {@Comp(type = Comp.Type.GTE, value = "1"), @Comp(type = Comp.Type.LTE, value = "2")}) + @Property(property = "fluidOutput", valid = {@Comp(type = Comp.Type.GTE, value = "1"), @Comp(type = Comp.Type.LTE, value = "3")}) + public static class RecipeBuilder extends AbstractRecipeBuilder { + + @Property(valid = @Comp(value = "0", type = Comp.Type.GTE)) + private int time; + + @RecipeBuilderMethodDescription + public RecipeBuilder time(int time) { + this.time = time; + return this; + } + + @Override + public String getErrorMsg() { + return "Error adding Immersive Technology Cooling Tower recipe"; + } + + @Override + public void validate(GroovyLog.Msg msg) { + validateItems(msg); + validateFluids(msg, 1, 2, 1, 3); + msg.add(time <= 0, "time must be greater than or equal to 1, yet it was {}", time); + } + + @Override + @RecipeBuilderRegistrationMethod + public @Nullable CoolingTowerRecipe register() { + if (!validate()) return null; + CoolingTowerRecipe recipe = new CoolingTowerRecipe(fluidOutput.get(0), fluidOutput.getOrEmpty(1), fluidOutput.getOrEmpty(2), fluidInput.get(0), fluidInput.getOrEmpty(1), time); + ModSupport.IMMERSIVE_TECHNOLOGY.get().coolingTower.add(recipe); + return recipe; + } + } + +} diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/Distiller.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/Distiller.java new file mode 100644 index 000000000..6dd45b790 --- /dev/null +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/Distiller.java @@ -0,0 +1,154 @@ +package com.cleanroommc.groovyscript.compat.mods.immersivetechnology; + +import com.cleanroommc.groovyscript.api.GroovyBlacklist; +import com.cleanroommc.groovyscript.api.GroovyLog; +import com.cleanroommc.groovyscript.api.IIngredient; +import com.cleanroommc.groovyscript.api.documentation.annotations.*; +import com.cleanroommc.groovyscript.compat.mods.ModSupport; +import com.cleanroommc.groovyscript.helper.SimpleObjectStream; +import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; +import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import mctmods.immersivetechnology.api.crafting.DistillerRecipe; +import mctmods.immersivetechnology.common.Config; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + +@RegistryDescription +public class Distiller extends VirtualizedRegistry { + + @Override + public boolean isEnabled() { + return Config.ITConfig.Machines.Multiblock.enable_distiller; + } + + @RecipeBuilderDescription(example = { + @Example(".fluidInput(fluid('lava') * 100).fluidOutput(fluid('hot_spring_water') * 500).time(100)"), + @Example(".fluidInput(fluid('water') * 50).fluidOutput(fluid('lava') * 50).output(item('minecraft:diamond')).chance(0.5f).time(50).energy(5000)") + }) + public RecipeBuilder recipeBuilder() { + return new RecipeBuilder(); + } + + @Override + @GroovyBlacklist + @ApiStatus.Internal + public void onReload() { + DistillerRecipe.recipeList.removeAll(removeScripted()); + DistillerRecipe.recipeList.addAll(restoreFromBackup()); + } + + public void add(DistillerRecipe recipe) { + if (recipe != null) { + addScripted(recipe); + DistillerRecipe.recipeList.add(recipe); + } + } + + public boolean remove(DistillerRecipe recipe) { + if (DistillerRecipe.recipeList.removeIf(r -> r == recipe)) { + addBackup(recipe); + return true; + } + return false; + } + + @MethodDescription(example = @Example(value = "fluid('water')", commented = true)) + public void removeByInput(IIngredient input) { + DistillerRecipe.recipeList.removeIf(r -> { + for (FluidStack fluidStack : r.getFluidInputs()) { + if (input.test(fluidStack)) { + addBackup(r); + return true; + } + } + return false; + }); + } + + @MethodDescription(example = {@Example("fluid('distwater')"), @Example(value = "item('immersivetech:material')", commented = true)}) + public void removeByOutput(IIngredient output) { + DistillerRecipe.recipeList.removeIf(r -> { + for (FluidStack fluidStack : r.getFluidOutputs()) { + if (output.test(fluidStack)) { + addBackup(r); + return true; + } + } + for (ItemStack itemStack : r.getItemOutputs()) { + if (output.test(itemStack)) { + addBackup(r); + return true; + } + } + return false; + }); + } + + @MethodDescription(type = MethodDescription.Type.QUERY) + public SimpleObjectStream streamRecipes() { + return new SimpleObjectStream<>(DistillerRecipe.recipeList).setRemover(this::remove); + } + + @MethodDescription(priority = 2000, example = @Example(commented = true)) + public void removeAll() { + DistillerRecipe.recipeList.forEach(this::addBackup); + DistillerRecipe.recipeList.clear(); + } + + @Property(property = "fluidInput", valid = @Comp("1")) + @Property(property = "fluidOutput", valid = @Comp("1")) + @Property(property = "output", valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "1")}) + public static class RecipeBuilder extends AbstractRecipeBuilder { + + @Property(valid = @Comp(value = "0", type = Comp.Type.GTE)) + private float chance; + @Property(valid = @Comp(value = "0", type = Comp.Type.GTE)) + private int time; + @Property(valid = @Comp(value = "0", type = Comp.Type.GTE)) + private int energy; + + @RecipeBuilderMethodDescription + public RecipeBuilder chance(float chance) { + this.chance = chance; + return this; + } + + @RecipeBuilderMethodDescription + public RecipeBuilder time(int time) { + this.time = time; + return this; + } + + @RecipeBuilderMethodDescription + public RecipeBuilder energy(int energy) { + this.energy = energy; + return this; + } + + @Override + public String getErrorMsg() { + return "Error adding Immersive Technology Distiller recipe"; + } + + @Override + public void validate(GroovyLog.Msg msg) { + validateItems(msg, 0, 0, 0, 1); + validateFluids(msg, 1, 1, 1, 1); + msg.add(time <= 0, "time must be greater than or equal to 1, yet it was {}", time); + msg.add(energy < 0, "energy must be a non negative integer, yet it was {}", energy); + msg.add(chance < 0 || chance > 1, "chance must be between 0 and 1, yet it was {}", chance); + } + + @Override + @RecipeBuilderRegistrationMethod + public @Nullable DistillerRecipe register() { + if (!validate()) return null; + DistillerRecipe recipe = new DistillerRecipe(fluidOutput.get(0), fluidInput.get(0), output.getOrEmpty(0), energy, time, chance); + ModSupport.IMMERSIVE_TECHNOLOGY.get().distiller.add(recipe); + return recipe; + } + } + +} diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/ElectrolyticCrucibleBattery.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/ElectrolyticCrucibleBattery.java new file mode 100644 index 000000000..222aa2cde --- /dev/null +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/ElectrolyticCrucibleBattery.java @@ -0,0 +1,139 @@ +package com.cleanroommc.groovyscript.compat.mods.immersivetechnology; + +import com.cleanroommc.groovyscript.api.GroovyBlacklist; +import com.cleanroommc.groovyscript.api.GroovyLog; +import com.cleanroommc.groovyscript.api.IIngredient; +import com.cleanroommc.groovyscript.api.documentation.annotations.*; +import com.cleanroommc.groovyscript.compat.mods.ModSupport; +import com.cleanroommc.groovyscript.helper.SimpleObjectStream; +import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; +import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import mctmods.immersivetechnology.api.crafting.ElectrolyticCrucibleBatteryRecipe; +import mctmods.immersivetechnology.common.Config; +import net.minecraftforge.fluids.FluidStack; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + +@RegistryDescription +public class ElectrolyticCrucibleBattery extends VirtualizedRegistry { + + @Override + public boolean isEnabled() { + return Config.ITConfig.Machines.Multiblock.enable_electrolyticCrucibleBattery; + } + + @RecipeBuilderDescription(example = { + @Example(".fluidInput(fluid('lava') * 100).fluidOutput(fluid('hot_spring_water') * 500).output(item('minecraft:clay')).time(100)"), + @Example(".fluidInput(fluid('water') * 500).fluidOutput(fluid('lava') * 50, fluid('hot_spring_water') * 50, fluid('water') * 400).output(item('minecraft:diamond')).time(50).energy(5000)") + }) + public RecipeBuilder recipeBuilder() { + return new RecipeBuilder(); + } + + @Override + @GroovyBlacklist + @ApiStatus.Internal + public void onReload() { + ElectrolyticCrucibleBatteryRecipe.recipeList.removeAll(removeScripted()); + ElectrolyticCrucibleBatteryRecipe.recipeList.addAll(restoreFromBackup()); + } + + public void add(ElectrolyticCrucibleBatteryRecipe recipe) { + if (recipe != null) { + addScripted(recipe); + ElectrolyticCrucibleBatteryRecipe.recipeList.add(recipe); + } + } + + public boolean remove(ElectrolyticCrucibleBatteryRecipe recipe) { + if (ElectrolyticCrucibleBatteryRecipe.recipeList.removeIf(r -> r == recipe)) { + addBackup(recipe); + return true; + } + return false; + } + + @MethodDescription(example = @Example("fluid('moltensalt')")) + public void removeByInput(IIngredient input) { + ElectrolyticCrucibleBatteryRecipe.recipeList.removeIf(r -> { + for (FluidStack fluidStack : r.getFluidInputs()) { + if (input.test(fluidStack)) { + addBackup(r); + return true; + } + } + return false; + }); + } + + @MethodDescription(example = @Example(value = "fluid('chlorine')", commented = true)) + public void removeByOutput(IIngredient output) { + ElectrolyticCrucibleBatteryRecipe.recipeList.removeIf(r -> { + for (FluidStack fluidStack : r.getFluidOutputs()) { + if (output.test(fluidStack)) { + addBackup(r); + return true; + } + } + return false; + }); + } + + @MethodDescription(type = MethodDescription.Type.QUERY) + public SimpleObjectStream streamRecipes() { + return new SimpleObjectStream<>(ElectrolyticCrucibleBatteryRecipe.recipeList).setRemover(this::remove); + } + + @MethodDescription(priority = 2000, example = @Example(commented = true)) + public void removeAll() { + ElectrolyticCrucibleBatteryRecipe.recipeList.forEach(this::addBackup); + ElectrolyticCrucibleBatteryRecipe.recipeList.clear(); + } + + @Property(property = "fluidInput", valid = @Comp("1")) + @Property(property = "fluidOutput", valid = {@Comp(type = Comp.Type.GTE, value = "1"), @Comp(type = Comp.Type.LTE, value = "3")}) + @Property(property = "output", valid = @Comp("1")) + public static class RecipeBuilder extends AbstractRecipeBuilder { + + @Property(valid = @Comp(value = "0", type = Comp.Type.GTE)) + private int time; + @Property(valid = @Comp(value = "0", type = Comp.Type.GTE)) + private int energy; + + + @RecipeBuilderMethodDescription + public RecipeBuilder time(int time) { + this.time = time; + return this; + } + + @RecipeBuilderMethodDescription + public RecipeBuilder energy(int energy) { + this.energy = energy; + return this; + } + + @Override + public String getErrorMsg() { + return "Error adding Immersive Technology Electrolytic Crucible Battery recipe"; + } + + @Override + public void validate(GroovyLog.Msg msg) { + validateItems(msg, 0, 0, 1, 1); + validateFluids(msg, 1, 1, 1, 3); + msg.add(time <= 0, "time must be greater than or equal to 1, yet it was {}", time); + msg.add(energy < 0, "energy must be a non negative integer, yet it was {}", energy); + } + + @Override + @RecipeBuilderRegistrationMethod + public @Nullable ElectrolyticCrucibleBatteryRecipe register() { + if (!validate()) return null; + ElectrolyticCrucibleBatteryRecipe recipe = new ElectrolyticCrucibleBatteryRecipe(fluidOutput.get(0), fluidOutput.getOrEmpty(1), fluidOutput.getOrEmpty(2), output.get(0), fluidInput.get(0), energy, time); + ModSupport.IMMERSIVE_TECHNOLOGY.get().electrolyticCrucibleBattery.add(recipe); + return recipe; + } + } + +} diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/GasTurbine.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/GasTurbine.java new file mode 100644 index 000000000..b0d641d33 --- /dev/null +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/GasTurbine.java @@ -0,0 +1,128 @@ +package com.cleanroommc.groovyscript.compat.mods.immersivetechnology; + +import com.cleanroommc.groovyscript.api.GroovyBlacklist; +import com.cleanroommc.groovyscript.api.GroovyLog; +import com.cleanroommc.groovyscript.api.IIngredient; +import com.cleanroommc.groovyscript.api.documentation.annotations.*; +import com.cleanroommc.groovyscript.compat.mods.ModSupport; +import com.cleanroommc.groovyscript.helper.SimpleObjectStream; +import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; +import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import mctmods.immersivetechnology.api.crafting.GasTurbineRecipe; +import mctmods.immersivetechnology.common.Config; +import net.minecraftforge.fluids.FluidStack; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + +@RegistryDescription +public class GasTurbine extends VirtualizedRegistry { + + @Override + public boolean isEnabled() { + return Config.ITConfig.Machines.Multiblock.enable_gasTurbine; + } + + @RecipeBuilderDescription(example = { + @Example(".fluidInput(fluid('lava') * 100).fluidOutput(fluid('hot_spring_water') * 500).time(100)"), + @Example(".fluidInput(fluid('water') * 50).fluidOutput(fluid('lava') * 50).time(50)") + }) + public RecipeBuilder recipeBuilder() { + return new RecipeBuilder(); + } + + @Override + @GroovyBlacklist + @ApiStatus.Internal + public void onReload() { + GasTurbineRecipe.recipeList.removeAll(removeScripted()); + GasTurbineRecipe.recipeList.addAll(restoreFromBackup()); + } + + public void add(GasTurbineRecipe recipe) { + if (recipe != null) { + addScripted(recipe); + GasTurbineRecipe.recipeList.add(recipe); + } + } + + public boolean remove(GasTurbineRecipe recipe) { + if (GasTurbineRecipe.recipeList.removeIf(r -> r == recipe)) { + addBackup(recipe); + return true; + } + return false; + } + + @MethodDescription(example = @Example("fluid('biodiesel')")) + public void removeByInput(IIngredient input) { + GasTurbineRecipe.recipeList.removeIf(r -> { + for (FluidStack fluidStack : r.getFluidInputs()) { + if (input.test(fluidStack)) { + addBackup(r); + return true; + } + } + return false; + }); + } + + @MethodDescription(example = @Example(value = "fluid('fluegas')",commented = true)) + public void removeByOutput(IIngredient output) { + GasTurbineRecipe.recipeList.removeIf(r -> { + for (FluidStack fluidStack : r.getFluidOutputs()) { + if (output.test(fluidStack)) { + addBackup(r); + return true; + } + } + return false; + }); + } + + @MethodDescription(type = MethodDescription.Type.QUERY) + public SimpleObjectStream streamRecipes() { + return new SimpleObjectStream<>(GasTurbineRecipe.recipeList).setRemover(this::remove); + } + + @MethodDescription(priority = 2000, example = @Example(commented = true)) + public void removeAll() { + GasTurbineRecipe.recipeList.forEach(this::addBackup); + GasTurbineRecipe.recipeList.clear(); + } + + @Property(property = "fluidInput", valid = @Comp("1")) + @Property(property = "fluidOutput", valid = @Comp("1")) + public static class RecipeBuilder extends AbstractRecipeBuilder { + + @Property(valid = @Comp(value = "0", type = Comp.Type.GTE)) + private int time; + + @RecipeBuilderMethodDescription + public RecipeBuilder time(int time) { + this.time = time; + return this; + } + + @Override + public String getErrorMsg() { + return "Error adding Immersive Technology Gas Turbine recipe"; + } + + @Override + public void validate(GroovyLog.Msg msg) { + validateItems(msg); + validateFluids(msg, 1, 1, 1, 1); + msg.add(time <= 0, "time must be greater than or equal to 1, yet it was {}", time); + } + + @Override + @RecipeBuilderRegistrationMethod + public @Nullable GasTurbineRecipe register() { + if (!validate()) return null; + GasTurbineRecipe recipe = new GasTurbineRecipe(fluidOutput.get(0), fluidInput.get(0), time); + ModSupport.IMMERSIVE_TECHNOLOGY.get().gasTurbine.add(recipe); + return recipe; + } + } + +} diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/HeatExchanger.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/HeatExchanger.java new file mode 100644 index 000000000..815d45440 --- /dev/null +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/HeatExchanger.java @@ -0,0 +1,137 @@ +package com.cleanroommc.groovyscript.compat.mods.immersivetechnology; + +import com.cleanroommc.groovyscript.api.GroovyBlacklist; +import com.cleanroommc.groovyscript.api.GroovyLog; +import com.cleanroommc.groovyscript.api.IIngredient; +import com.cleanroommc.groovyscript.api.documentation.annotations.*; +import com.cleanroommc.groovyscript.compat.mods.ModSupport; +import com.cleanroommc.groovyscript.helper.SimpleObjectStream; +import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; +import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import mctmods.immersivetechnology.api.crafting.HeatExchangerRecipe; +import mctmods.immersivetechnology.common.Config; +import net.minecraftforge.fluids.FluidStack; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + +@RegistryDescription +public class HeatExchanger extends VirtualizedRegistry { + + @Override + public boolean isEnabled() { + return Config.ITConfig.Machines.Multiblock.enable_heatExchanger; + } + + @RecipeBuilderDescription(example = { + @Example(".fluidInput(fluid('lava') * 100, fluid('lava') * 50).fluidOutput(fluid('hot_spring_water') * 500).time(100)"), + @Example(".fluidInput(fluid('water') * 50, fluid('hot_spring_water') * 50).fluidOutput(fluid('lava') * 50, fluid('water') * 10).time(50).energy(5000)") + }) + public RecipeBuilder recipeBuilder() { + return new RecipeBuilder(); + } + + @Override + @GroovyBlacklist + @ApiStatus.Internal + public void onReload() { + HeatExchangerRecipe.recipeList.removeAll(removeScripted()); + HeatExchangerRecipe.recipeList.addAll(restoreFromBackup()); + } + + public void add(HeatExchangerRecipe recipe) { + if (recipe != null) { + addScripted(recipe); + HeatExchangerRecipe.recipeList.add(recipe); + } + } + + public boolean remove(HeatExchangerRecipe recipe) { + if (HeatExchangerRecipe.recipeList.removeIf(r -> r == recipe)) { + addBackup(recipe); + return true; + } + return false; + } + + @MethodDescription(example = @Example("fluid('fluegas')")) + public void removeByInput(IIngredient input) { + HeatExchangerRecipe.recipeList.removeIf(r -> { + for (FluidStack fluidStack : r.getFluidInputs()) { + if (input.test(fluidStack)) { + addBackup(r); + return true; + } + } + return false; + }); + } + + @MethodDescription(example = @Example("fluid('hot_spring_water')")) + public void removeByOutput(IIngredient output) { + HeatExchangerRecipe.recipeList.removeIf(r -> { + // would iterate through r.getFluidOutputs() as with the other IE compats, but they forgot to define it so its null. + if (output.test(r.fluidOutput0) || output.test(r.fluidOutput1)) { + addBackup(r); + return true; + } + return false; + }); + } + + @MethodDescription(type = MethodDescription.Type.QUERY) + public SimpleObjectStream streamRecipes() { + return new SimpleObjectStream<>(HeatExchangerRecipe.recipeList).setRemover(this::remove); + } + + @MethodDescription(priority = 2000, example = @Example(commented = true)) + public void removeAll() { + HeatExchangerRecipe.recipeList.forEach(this::addBackup); + HeatExchangerRecipe.recipeList.clear(); + } + + @Property(property = "fluidInput", valid = @Comp("2")) + @Property(property = "fluidOutput", valid = {@Comp(type = Comp.Type.GTE, value = "1"), @Comp(type = Comp.Type.LTE, value = "2")}) + public static class RecipeBuilder extends AbstractRecipeBuilder { + + @Property(valid = @Comp(value = "0", type = Comp.Type.GTE)) + private int time; + @Property(valid = @Comp(value = "0", type = Comp.Type.GTE)) + private int energy; + + + @RecipeBuilderMethodDescription + public RecipeBuilder time(int time) { + this.time = time; + return this; + } + + @RecipeBuilderMethodDescription + public RecipeBuilder energy(int energy) { + this.energy = energy; + return this; + } + + @Override + public String getErrorMsg() { + return "Error adding Immersive Technology Heat Exchanger recipe"; + } + + @Override + public void validate(GroovyLog.Msg msg) { + validateItems(msg); + validateFluids(msg, 2, 2, 1, 2); + msg.add(time <= 0, "time must be greater than or equal to 1, yet it was {}", time); + msg.add(energy < 0, "energy must be a non negative integer, yet it was {}", energy); + } + + @Override + @RecipeBuilderRegistrationMethod + public @Nullable HeatExchangerRecipe register() { + if (!validate()) return null; + HeatExchangerRecipe recipe = new HeatExchangerRecipe(fluidOutput.get(0), fluidOutput.getOrEmpty(1), fluidInput.get(0), fluidInput.get(1), energy, time); + ModSupport.IMMERSIVE_TECHNOLOGY.get().heatExchanger.add(recipe); + return recipe; + } + } + +} diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/HighPressureSteamTurbine.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/HighPressureSteamTurbine.java new file mode 100644 index 000000000..752c321ea --- /dev/null +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/HighPressureSteamTurbine.java @@ -0,0 +1,128 @@ +package com.cleanroommc.groovyscript.compat.mods.immersivetechnology; + +import com.cleanroommc.groovyscript.api.GroovyBlacklist; +import com.cleanroommc.groovyscript.api.GroovyLog; +import com.cleanroommc.groovyscript.api.IIngredient; +import com.cleanroommc.groovyscript.api.documentation.annotations.*; +import com.cleanroommc.groovyscript.compat.mods.ModSupport; +import com.cleanroommc.groovyscript.helper.SimpleObjectStream; +import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; +import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import mctmods.immersivetechnology.api.crafting.HighPressureSteamTurbineRecipe; +import mctmods.immersivetechnology.common.Config; +import net.minecraftforge.fluids.FluidStack; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + +@RegistryDescription +public class HighPressureSteamTurbine extends VirtualizedRegistry { + + @Override + public boolean isEnabled() { + return Config.ITConfig.Machines.Multiblock.enable_highPressureSteamTurbine; + } + + @RecipeBuilderDescription(example = { + @Example(".fluidInput(fluid('lava') * 100).fluidOutput(fluid('hot_spring_water') * 500).time(100)"), + @Example(".fluidInput(fluid('water') * 50).fluidOutput(fluid('lava') * 50).time(50)") + }) + public RecipeBuilder recipeBuilder() { + return new RecipeBuilder(); + } + + @Override + @GroovyBlacklist + @ApiStatus.Internal + public void onReload() { + HighPressureSteamTurbineRecipe.recipeList.removeAll(removeScripted()); + HighPressureSteamTurbineRecipe.recipeList.addAll(restoreFromBackup()); + } + + public void add(HighPressureSteamTurbineRecipe recipe) { + if (recipe != null) { + addScripted(recipe); + HighPressureSteamTurbineRecipe.recipeList.add(recipe); + } + } + + public boolean remove(HighPressureSteamTurbineRecipe recipe) { + if (HighPressureSteamTurbineRecipe.recipeList.removeIf(r -> r == recipe)) { + addBackup(recipe); + return true; + } + return false; + } + + @MethodDescription(example = @Example("fluid('highpressuresteam')")) + public void removeByInput(IIngredient input) { + HighPressureSteamTurbineRecipe.recipeList.removeIf(r -> { + for (FluidStack fluidStack : r.getFluidInputs()) { + if (input.test(fluidStack)) { + addBackup(r); + return true; + } + } + return false; + }); + } + + @MethodDescription(example = @Example(value = "fluid('steam')",commented = true)) + public void removeByOutput(IIngredient output) { + HighPressureSteamTurbineRecipe.recipeList.removeIf(r -> { + for (FluidStack fluidStack : r.getFluidOutputs()) { + if (output.test(fluidStack)) { + addBackup(r); + return true; + } + } + return false; + }); + } + + @MethodDescription(type = MethodDescription.Type.QUERY) + public SimpleObjectStream streamRecipes() { + return new SimpleObjectStream<>(HighPressureSteamTurbineRecipe.recipeList).setRemover(this::remove); + } + + @MethodDescription(priority = 2000, example = @Example(commented = true)) + public void removeAll() { + HighPressureSteamTurbineRecipe.recipeList.forEach(this::addBackup); + HighPressureSteamTurbineRecipe.recipeList.clear(); + } + + @Property(property = "fluidInput", valid = @Comp("1")) + @Property(property = "fluidOutput", valid = @Comp("1")) + public static class RecipeBuilder extends AbstractRecipeBuilder { + + @Property(valid = @Comp(value = "0", type = Comp.Type.GTE)) + private int time; + + @RecipeBuilderMethodDescription + public RecipeBuilder time(int time) { + this.time = time; + return this; + } + + @Override + public String getErrorMsg() { + return "Error adding Immersive Technology High Pressure Steam Turbine recipe"; + } + + @Override + public void validate(GroovyLog.Msg msg) { + validateItems(msg); + validateFluids(msg, 1, 1, 1, 1); + msg.add(time <= 0, "time must be greater than or equal to 1, yet it was {}", time); + } + + @Override + @RecipeBuilderRegistrationMethod + public @Nullable HighPressureSteamTurbineRecipe register() { + if (!validate()) return null; + HighPressureSteamTurbineRecipe recipe = new HighPressureSteamTurbineRecipe(fluidOutput.get(0), fluidInput.get(0), time); + ModSupport.IMMERSIVE_TECHNOLOGY.get().highPressureSteamTurbine.add(recipe); + return recipe; + } + } + +} diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/ImmersiveTechnology.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/ImmersiveTechnology.java new file mode 100644 index 000000000..2a30c1eca --- /dev/null +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/ImmersiveTechnology.java @@ -0,0 +1,20 @@ +package com.cleanroommc.groovyscript.compat.mods.immersivetechnology; + +import com.cleanroommc.groovyscript.compat.mods.GroovyPropertyContainer; + +public class ImmersiveTechnology extends GroovyPropertyContainer { + + public final Boiler boiler = new Boiler(); + public final BoilerFuel boilerFuel = new BoilerFuel(); + public final CoolingTower coolingTower = new CoolingTower(); + public final Distiller distiller = new Distiller(); + public final ElectrolyticCrucibleBattery electrolyticCrucibleBattery = new ElectrolyticCrucibleBattery(); + public final GasTurbine gasTurbine = new GasTurbine(); + public final HeatExchanger heatExchanger = new HeatExchanger(); + public final HighPressureSteamTurbine highPressureSteamTurbine = new HighPressureSteamTurbine(); + public final MeltingCrucible meltingCrucible = new MeltingCrucible(); + public final Radiator radiator = new Radiator(); + public final SolarTower solarTower = new SolarTower(); + public final SteamTurbine steamTurbine = new SteamTurbine(); + +} diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/MeltingCrucible.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/MeltingCrucible.java new file mode 100644 index 000000000..5c5e1f48e --- /dev/null +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/MeltingCrucible.java @@ -0,0 +1,137 @@ +package com.cleanroommc.groovyscript.compat.mods.immersivetechnology; + +import blusunrize.immersiveengineering.api.crafting.IngredientStack; +import com.cleanroommc.groovyscript.api.GroovyBlacklist; +import com.cleanroommc.groovyscript.api.GroovyLog; +import com.cleanroommc.groovyscript.api.IIngredient; +import com.cleanroommc.groovyscript.api.documentation.annotations.*; +import com.cleanroommc.groovyscript.compat.mods.ModSupport; +import com.cleanroommc.groovyscript.compat.mods.immersiveengineering.ImmersiveEngineering; +import com.cleanroommc.groovyscript.helper.SimpleObjectStream; +import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; +import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import mctmods.immersivetechnology.api.crafting.MeltingCrucibleRecipe; +import mctmods.immersivetechnology.common.Config; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + +@RegistryDescription +public class MeltingCrucible extends VirtualizedRegistry { + + @Override + public boolean isEnabled() { + return Config.ITConfig.Machines.Multiblock.enable_meltingCrucible; + } + + @RecipeBuilderDescription(example = { + @Example(".input(item('minecraft:diamond')).fluidOutput(fluid('hot_spring_water')).time(100)"), + @Example(".input(item('minecraft:clay') * 8).fluidOutput(fluid('lava') * 50).time(50).energy(5000)") + }) + public RecipeBuilder recipeBuilder() { + return new RecipeBuilder(); + } + + @Override + @GroovyBlacklist + @ApiStatus.Internal + public void onReload() { + MeltingCrucibleRecipe.recipeList.removeAll(removeScripted()); + MeltingCrucibleRecipe.recipeList.addAll(restoreFromBackup()); + } + + public void add(MeltingCrucibleRecipe recipe) { + if (recipe != null) { + addScripted(recipe); + MeltingCrucibleRecipe.recipeList.add(recipe); + } + } + + public boolean remove(MeltingCrucibleRecipe recipe) { + if (MeltingCrucibleRecipe.recipeList.removeIf(r -> r == recipe)) { + addBackup(recipe); + return true; + } + return false; + } + + @MethodDescription(example = @Example("item('minecraft:cobblestone')")) + public void removeByInput(IIngredient input) { + MeltingCrucibleRecipe.recipeList.removeIf(r -> { + for (IngredientStack ingredientStack : r.getItemInputs()) { + if (ImmersiveEngineering.areIngredientsEquals(ingredientStack, input)) { + addBackup(r); + return true; + } + } + return false; + }); + } + + @MethodDescription(example = @Example("fluid('moltensalt')")) + public void removeByOutput(IIngredient output) { + MeltingCrucibleRecipe.recipeList.removeIf(r -> { + // would iterate through r.getFluidOutputs() as with the other IE compats, but they forgot to define it so its null. + if (output.test(r.fluidOutput)) { + addBackup(r); + return true; + } + return false; + }); + } + + @MethodDescription(type = MethodDescription.Type.QUERY) + public SimpleObjectStream streamRecipes() { + return new SimpleObjectStream<>(MeltingCrucibleRecipe.recipeList).setRemover(this::remove); + } + + @MethodDescription(priority = 2000, example = @Example(commented = true)) + public void removeAll() { + MeltingCrucibleRecipe.recipeList.forEach(this::addBackup); + MeltingCrucibleRecipe.recipeList.clear(); + } + + @Property(property = "input", valid = @Comp("1")) + @Property(property = "fluidOutput", valid = @Comp("1")) + public static class RecipeBuilder extends AbstractRecipeBuilder { + + @Property(valid = @Comp(value = "0", type = Comp.Type.GTE)) + private int time; + @Property(valid = @Comp(value = "0", type = Comp.Type.GTE)) + private int energy; + + @RecipeBuilderMethodDescription + public RecipeBuilder time(int time) { + this.time = time; + return this; + } + + @RecipeBuilderMethodDescription + public RecipeBuilder energy(int energy) { + this.energy = energy; + return this; + } + + @Override + public String getErrorMsg() { + return "Error adding Immersive Technology Melting Crucible recipe"; + } + + @Override + public void validate(GroovyLog.Msg msg) { + validateItems(msg, 1, 1, 0, 0); + validateFluids(msg, 0, 0, 1, 1); + msg.add(time <= 0, "time must be greater than or equal to 1, yet it was {}", time); + msg.add(energy < 0, "energy must be a non negative integer, yet it was {}", energy); + } + + @Override + @RecipeBuilderRegistrationMethod + public @Nullable MeltingCrucibleRecipe register() { + if (!validate()) return null; + MeltingCrucibleRecipe recipe = new MeltingCrucibleRecipe(fluidOutput.get(0), ImmersiveEngineering.toIngredientStack(input.get(0)), energy, time); + ModSupport.IMMERSIVE_TECHNOLOGY.get().meltingCrucible.add(recipe); + return recipe; + } + } + +} diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/Radiator.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/Radiator.java new file mode 100644 index 000000000..b57aa8f9f --- /dev/null +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/Radiator.java @@ -0,0 +1,128 @@ +package com.cleanroommc.groovyscript.compat.mods.immersivetechnology; + +import com.cleanroommc.groovyscript.api.GroovyBlacklist; +import com.cleanroommc.groovyscript.api.GroovyLog; +import com.cleanroommc.groovyscript.api.IIngredient; +import com.cleanroommc.groovyscript.api.documentation.annotations.*; +import com.cleanroommc.groovyscript.compat.mods.ModSupport; +import com.cleanroommc.groovyscript.helper.SimpleObjectStream; +import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; +import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import mctmods.immersivetechnology.api.crafting.RadiatorRecipe; +import mctmods.immersivetechnology.common.Config; +import net.minecraftforge.fluids.FluidStack; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + +@RegistryDescription +public class Radiator extends VirtualizedRegistry { + + @Override + public boolean isEnabled() { + return Config.ITConfig.Machines.Multiblock.enable_radiator; + } + + @RecipeBuilderDescription(example = { + @Example(".fluidInput(fluid('lava') * 100).fluidOutput(fluid('hot_spring_water') * 500).time(100)"), + @Example(".fluidInput(fluid('water') * 50).fluidOutput(fluid('lava') * 50).time(50)") + }) + public RecipeBuilder recipeBuilder() { + return new RecipeBuilder(); + } + + @Override + @GroovyBlacklist + @ApiStatus.Internal + public void onReload() { + RadiatorRecipe.recipeList.removeAll(removeScripted()); + RadiatorRecipe.recipeList.addAll(restoreFromBackup()); + } + + public void add(RadiatorRecipe recipe) { + if (recipe != null) { + addScripted(recipe); + RadiatorRecipe.recipeList.add(recipe); + } + } + + public boolean remove(RadiatorRecipe recipe) { + if (RadiatorRecipe.recipeList.removeIf(r -> r == recipe)) { + addBackup(recipe); + return true; + } + return false; + } + + @MethodDescription(example = @Example("fluid('exhauststeam')")) + public void removeByInput(IIngredient input) { + RadiatorRecipe.recipeList.removeIf(r -> { + for (FluidStack fluidStack : r.getFluidInputs()) { + if (input.test(fluidStack)) { + addBackup(r); + return true; + } + } + return false; + }); + } + + @MethodDescription(example = @Example(value = "fluid('distwater')",commented = true)) + public void removeByOutput(IIngredient output) { + RadiatorRecipe.recipeList.removeIf(r -> { + for (FluidStack fluidStack : r.getFluidOutputs()) { + if (output.test(fluidStack)) { + addBackup(r); + return true; + } + } + return false; + }); + } + + @MethodDescription(type = MethodDescription.Type.QUERY) + public SimpleObjectStream streamRecipes() { + return new SimpleObjectStream<>(RadiatorRecipe.recipeList).setRemover(this::remove); + } + + @MethodDescription(priority = 2000, example = @Example(commented = true)) + public void removeAll() { + RadiatorRecipe.recipeList.forEach(this::addBackup); + RadiatorRecipe.recipeList.clear(); + } + + @Property(property = "fluidInput", valid = @Comp("1")) + @Property(property = "fluidOutput", valid = @Comp("1")) + public static class RecipeBuilder extends AbstractRecipeBuilder { + + @Property(valid = @Comp(value = "0", type = Comp.Type.GTE)) + private int time; + + @RecipeBuilderMethodDescription + public RecipeBuilder time(int time) { + this.time = time; + return this; + } + + @Override + public String getErrorMsg() { + return "Error adding Immersive Technology Radiator recipe"; + } + + @Override + public void validate(GroovyLog.Msg msg) { + validateItems(msg); + validateFluids(msg, 1, 1, 1, 1); + msg.add(time <= 0, "time must be greater than or equal to 1, yet it was {}", time); + } + + @Override + @RecipeBuilderRegistrationMethod + public @Nullable RadiatorRecipe register() { + if (!validate()) return null; + RadiatorRecipe recipe = new RadiatorRecipe(fluidOutput.get(0), fluidInput.get(0), time); + ModSupport.IMMERSIVE_TECHNOLOGY.get().radiator.add(recipe); + return recipe; + } + } + +} diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/SolarTower.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/SolarTower.java new file mode 100644 index 000000000..bbfc4dd41 --- /dev/null +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/SolarTower.java @@ -0,0 +1,128 @@ +package com.cleanroommc.groovyscript.compat.mods.immersivetechnology; + +import com.cleanroommc.groovyscript.api.GroovyBlacklist; +import com.cleanroommc.groovyscript.api.GroovyLog; +import com.cleanroommc.groovyscript.api.IIngredient; +import com.cleanroommc.groovyscript.api.documentation.annotations.*; +import com.cleanroommc.groovyscript.compat.mods.ModSupport; +import com.cleanroommc.groovyscript.helper.SimpleObjectStream; +import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; +import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import mctmods.immersivetechnology.api.crafting.SolarTowerRecipe; +import mctmods.immersivetechnology.common.Config; +import net.minecraftforge.fluids.FluidStack; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + +@RegistryDescription +public class SolarTower extends VirtualizedRegistry { + + @Override + public boolean isEnabled() { + return Config.ITConfig.Machines.Multiblock.enable_solarTower; + } + + @RecipeBuilderDescription(example = { + @Example(".fluidInput(fluid('lava') * 100).fluidOutput(fluid('hot_spring_water') * 500).time(100)"), + @Example(".fluidInput(fluid('water') * 50).fluidOutput(fluid('lava') * 50).time(50)") + }) + public RecipeBuilder recipeBuilder() { + return new RecipeBuilder(); + } + + @Override + @GroovyBlacklist + @ApiStatus.Internal + public void onReload() { + SolarTowerRecipe.recipeList.removeAll(removeScripted()); + SolarTowerRecipe.recipeList.addAll(restoreFromBackup()); + } + + public void add(SolarTowerRecipe recipe) { + if (recipe != null) { + addScripted(recipe); + SolarTowerRecipe.recipeList.add(recipe); + } + } + + public boolean remove(SolarTowerRecipe recipe) { + if (SolarTowerRecipe.recipeList.removeIf(r -> r == recipe)) { + addBackup(recipe); + return true; + } + return false; + } + + @MethodDescription(example = @Example("fluid('water')")) + public void removeByInput(IIngredient input) { + SolarTowerRecipe.recipeList.removeIf(r -> { + for (FluidStack fluidStack : r.getFluidInputs()) { + if (input.test(fluidStack)) { + addBackup(r); + return true; + } + } + return false; + }); + } + + @MethodDescription(example = @Example("fluid('superheatedmoltensodium')")) + public void removeByOutput(IIngredient output) { + SolarTowerRecipe.recipeList.removeIf(r -> { + for (FluidStack fluidStack : r.getFluidOutputs()) { + if (output.test(fluidStack)) { + addBackup(r); + return true; + } + } + return false; + }); + } + + @MethodDescription(type = MethodDescription.Type.QUERY) + public SimpleObjectStream streamRecipes() { + return new SimpleObjectStream<>(SolarTowerRecipe.recipeList).setRemover(this::remove); + } + + @MethodDescription(priority = 2000, example = @Example(commented = true)) + public void removeAll() { + SolarTowerRecipe.recipeList.forEach(this::addBackup); + SolarTowerRecipe.recipeList.clear(); + } + + @Property(property = "fluidInput", valid = @Comp("1")) + @Property(property = "fluidOutput", valid = @Comp("1")) + public static class RecipeBuilder extends AbstractRecipeBuilder { + + @Property(valid = @Comp(value = "0", type = Comp.Type.GTE)) + private int time; + + @RecipeBuilderMethodDescription + public RecipeBuilder time(int time) { + this.time = time; + return this; + } + + @Override + public String getErrorMsg() { + return "Error adding Immersive Technology Solar Tower recipe"; + } + + @Override + public void validate(GroovyLog.Msg msg) { + validateItems(msg); + validateFluids(msg, 1, 1, 1, 1); + msg.add(time <= 0, "time must be greater than or equal to 1, yet it was {}", time); + } + + @Override + @RecipeBuilderRegistrationMethod + public @Nullable SolarTowerRecipe register() { + if (!validate()) return null; + SolarTowerRecipe recipe = new SolarTowerRecipe(fluidOutput.get(0), fluidInput.get(0), time); + ModSupport.IMMERSIVE_TECHNOLOGY.get().solarTower.add(recipe); + return recipe; + } + } + +} diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/SteamTurbine.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/SteamTurbine.java new file mode 100644 index 000000000..cf35f9c3b --- /dev/null +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/SteamTurbine.java @@ -0,0 +1,128 @@ +package com.cleanroommc.groovyscript.compat.mods.immersivetechnology; + +import com.cleanroommc.groovyscript.api.GroovyBlacklist; +import com.cleanroommc.groovyscript.api.GroovyLog; +import com.cleanroommc.groovyscript.api.IIngredient; +import com.cleanroommc.groovyscript.api.documentation.annotations.*; +import com.cleanroommc.groovyscript.compat.mods.ModSupport; +import com.cleanroommc.groovyscript.helper.SimpleObjectStream; +import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; +import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import mctmods.immersivetechnology.api.crafting.SteamTurbineRecipe; +import mctmods.immersivetechnology.common.Config; +import net.minecraftforge.fluids.FluidStack; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + +@RegistryDescription +public class SteamTurbine extends VirtualizedRegistry { + + @Override + public boolean isEnabled() { + return Config.ITConfig.Machines.Multiblock.enable_steamTurbine; + } + + @RecipeBuilderDescription(example = { + @Example(".fluidInput(fluid('lava') * 100).fluidOutput(fluid('hot_spring_water') * 500).time(100)"), + @Example(".fluidInput(fluid('water') * 50).fluidOutput(fluid('lava') * 50).time(50)") + }) + public RecipeBuilder recipeBuilder() { + return new RecipeBuilder(); + } + + @Override + @GroovyBlacklist + @ApiStatus.Internal + public void onReload() { + SteamTurbineRecipe.recipeList.removeAll(removeScripted()); + SteamTurbineRecipe.recipeList.addAll(restoreFromBackup()); + } + + public void add(SteamTurbineRecipe recipe) { + if (recipe != null) { + addScripted(recipe); + SteamTurbineRecipe.recipeList.add(recipe); + } + } + + public boolean remove(SteamTurbineRecipe recipe) { + if (SteamTurbineRecipe.recipeList.removeIf(r -> r == recipe)) { + addBackup(recipe); + return true; + } + return false; + } + + @MethodDescription(example = @Example("fluid('steam')")) + public void removeByInput(IIngredient input) { + SteamTurbineRecipe.recipeList.removeIf(r -> { + for (FluidStack fluidStack : r.getFluidInputs()) { + if (input.test(fluidStack)) { + addBackup(r); + return true; + } + } + return false; + }); + } + + @MethodDescription(example = @Example(value = "fluid('exhauststeam')", commented = true)) + public void removeByOutput(IIngredient output) { + SteamTurbineRecipe.recipeList.removeIf(r -> { + for (FluidStack fluidStack : r.getFluidOutputs()) { + if (output.test(fluidStack)) { + addBackup(r); + return true; + } + } + return false; + }); + } + + @MethodDescription(type = MethodDescription.Type.QUERY) + public SimpleObjectStream streamRecipes() { + return new SimpleObjectStream<>(SteamTurbineRecipe.recipeList).setRemover(this::remove); + } + + @MethodDescription(priority = 2000, example = @Example(commented = true)) + public void removeAll() { + SteamTurbineRecipe.recipeList.forEach(this::addBackup); + SteamTurbineRecipe.recipeList.clear(); + } + + @Property(property = "fluidInput", valid = @Comp("1")) + @Property(property = "fluidOutput", valid = @Comp("1")) + public static class RecipeBuilder extends AbstractRecipeBuilder { + + @Property(valid = @Comp(value = "0", type = Comp.Type.GTE)) + private int time; + + @RecipeBuilderMethodDescription + public RecipeBuilder time(int time) { + this.time = time; + return this; + } + + @Override + public String getErrorMsg() { + return "Error adding Immersive Technology Steam Turbine recipe"; + } + + @Override + public void validate(GroovyLog.Msg msg) { + validateItems(msg); + validateFluids(msg, 1, 1, 1, 1); + msg.add(time <= 0, "time must be greater than or equal to 1, yet it was {}", time); + } + + @Override + @RecipeBuilderRegistrationMethod + public @Nullable SteamTurbineRecipe register() { + if (!validate()) return null; + SteamTurbineRecipe recipe = new SteamTurbineRecipe(fluidOutput.get(0), fluidInput.get(0), time); + ModSupport.IMMERSIVE_TECHNOLOGY.get().steamTurbine.add(recipe); + return recipe; + } + } + +} diff --git a/src/main/resources/assets/groovyscript/lang/en_us.lang b/src/main/resources/assets/groovyscript/lang/en_us.lang index 170fbfd80..f8cfca413 100644 --- a/src/main/resources/assets/groovyscript/lang/en_us.lang +++ b/src/main/resources/assets/groovyscript/lang/en_us.lang @@ -1122,6 +1122,62 @@ groovyscript.wiki.immersivepetroleum.reservoir.dimensionBlacklist.value=Sets if groovyscript.wiki.immersivepetroleum.reservoir.removeByName=Removes the Reservoir entry with the given name +# Immersive Technology +groovyscript.wiki.immersivetech.boiler.title=Boiler +groovyscript.wiki.immersivetech.boiler.description=Converts an input fluidstack into an output fluidstack after a given amount of time in a multiblock structure when the multiblock has had its heat value increased enough by fuel. +groovyscript.wiki.immersivetech.boiler.time.value=Sets the time in ticks the recipe takes to process + +groovyscript.wiki.immersivetech.boiler_fuel.title=Boiler Fuel +groovyscript.wiki.immersivetech.boiler_fuel.description=Converts an input fluidstack into heat for the Boiler multiblock structure over a given amount of time. +groovyscript.wiki.immersivetech.boiler_fuel.heat.value=Sets the total heat gained by the Boiler +groovyscript.wiki.immersivetech.boiler_fuel.time.value=Sets the time in ticks the recipe takes to process + +groovyscript.wiki.immersivetech.cooling_tower.title=Cooling Tower +groovyscript.wiki.immersivetech.cooling_tower.description=Converts up to two input fluidstacks into up to three output fluidstacks after a given amount of time in a multiblock structure. +groovyscript.wiki.immersivetech.cooling_tower.time.value=Sets the time in ticks the recipe takes to process + +groovyscript.wiki.immersivetech.distiller.title=Distiller +groovyscript.wiki.immersivetech.distiller.description=Converts an input fluidstack into an output fluidstack and has a chance to output an itemstack after a given amount of time in a multiblock structure. +groovyscript.wiki.immersivetech.distiller.time.value=Sets the time in ticks the recipe takes to process +groovyscript.wiki.immersivetech.distiller.chance.value=Sets the chance the output itemstack with be output +groovyscript.wiki.immersivetech.distiller.energy.value=Sets the energy used in total IF consumed by the recipe + +groovyscript.wiki.immersivetech.electrolytic_crucible_battery.title=Electrolytic Crucible Battery +groovyscript.wiki.immersivetech.electrolytic_crucible_battery.description=Converts an input fluidstack into up to three output fluidstacks after a given amount of time and energy in a multiblock structure. +groovyscript.wiki.immersivetech.electrolytic_crucible_battery.time.value=Sets the time in ticks the recipe takes to process +groovyscript.wiki.immersivetech.electrolytic_crucible_battery.energy.value=Sets the energy used in total IF consumed by the recipe + +groovyscript.wiki.immersivetech.gas_turbine.title=Gas Turbine +groovyscript.wiki.immersivetech.gas_turbine.description=Converts an input fluidstack into an output fluidstack after a given amount of time in a multiblock structure, producing power for an adjacent Alternator multiblock. +groovyscript.wiki.immersivetech.gas_turbine.time.value=Sets the time in ticks the recipe takes to process + +groovyscript.wiki.immersivetech.heat_exchanger.title=Heat Exchanger +groovyscript.wiki.immersivetech.heat_exchanger.description=Converts up to two input fluidstacks into up to two output fluidstacks after a given amount of time in a multiblock structure. +groovyscript.wiki.immersivetech.heat_exchanger.time.value=Sets the time in ticks the recipe takes to process +groovyscript.wiki.immersivetech.heat_exchanger.energy.value=Sets the energy used in total IF consumed by the recipe + +groovyscript.wiki.immersivetech.high_pressure_steam_turbine.title=High-Pressure Steam Turbine +groovyscript.wiki.immersivetech.high_pressure_steam_turbine.description=Converts an input fluidstack into an output fluidstack after a given amount of time in a multiblock structure, producing power for an adjacent Alternator multiblock. +groovyscript.wiki.immersivetech.high_pressure_steam_turbine.time.value=Sets the time in ticks the recipe takes to process + +groovyscript.wiki.immersivetech.melting_crucible.title=Melting Crucible +groovyscript.wiki.immersivetech.melting_crucible.description=Converts an input itemstack into an output fluidstack after a given amount of time and energy in a multiblock structure. +groovyscript.wiki.immersivetech.melting_crucible.time.value=Sets the time in ticks the recipe takes to process +groovyscript.wiki.immersivetech.melting_crucible.energy.value=Sets the energy used in total IF consumed by the recipe + +groovyscript.wiki.immersivetech.radiator.title=Radiator +groovyscript.wiki.immersivetech.radiator.description=Converts an input fluidstack into an output fluidstack after a given amount of time in a multiblock structure. +groovyscript.wiki.immersivetech.radiator.time.value=Sets the time in ticks the recipe takes to process + +groovyscript.wiki.immersivetech.solar_tower.title=Solar Tower +groovyscript.wiki.immersivetech.solar_tower.description=Converts an input fluidstack into an output fluidstack after a given amount of time in a multiblock structure, with the time being able to be sped up via Solar Reflector multiblocks. +groovyscript.wiki.immersivetech.solar_tower.time.value=Sets the time in ticks the recipe takes to process + +groovyscript.wiki.immersivetech.steam_turbine.title=Steam Turbine +groovyscript.wiki.immersivetech.steam_turbine.description=Converts an input fluidstack into an output fluidstack after a given amount of time in a multiblock structure, producing power for an adjacent Alternator multiblock. +groovyscript.wiki.immersivetech.steam_turbine.time.value=Sets the time in ticks the recipe takes to process + + # Industrial Foregoing groovyscript.wiki.industrialforegoing.bio_reactor.title=Bioreactor groovyscript.wiki.industrialforegoing.bio_reactor.description=Converts an input item into Biofuel, with the amount of Biofuel generated being based on the number of concurrent conversion processes inside the Bioreactor.