diff --git a/dependencies.gradle b/dependencies.gradle index 5a1211f19..a1eb26f7c 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -235,6 +235,11 @@ dependencies { runtimeOnly rfg.deobf('curse.maven:advancedmortars-283777:2780626') } + compileOnly rfg.deobf('curse.maven:aether-255308:3280119') + if (project.debug_aether.toBoolean()) { + runtimeOnly rfg.deobf('curse.maven:aether-255308:3280119') + } + compileOnly rfg.deobf('curse.maven:pyrotech-306676:4956838') compileOnly rfg.deobf('curse.maven:athenaeum-284350:4633750') @@ -244,7 +249,6 @@ dependencies { runtimeOnly rfg.deobf("curse.maven:dropt-284973:3758733") } - } minecraft { diff --git a/examples/postInit/aether_legacy.groovy b/examples/postInit/aether_legacy.groovy new file mode 100644 index 000000000..5d4bdb7ea --- /dev/null +++ b/examples/postInit/aether_legacy.groovy @@ -0,0 +1,63 @@ + +// Auto generated groovyscript example file +// MODS_LOADED: aether_legacy + +println 'mod \'aether_legacy\' detected, running script' + +// Accessory: +// The Aether Accessory system. + +mods.aether_legacy.accessory.removeByInput(item('aether_legacy:iron_pendant')) +// mods.aether_legacy.accessory.removeAll() + +mods.aether_legacy.accessory.recipeBuilder() + .input(item('minecraft:shield')) + .accessoryType('shield') + .register() + + + +// Enchanter: +// Enchanting is a mechanic used to create new items, as well as repair tools, armor, and weapons, using the Altar block. + +mods.aether_legacy.enchanter.removeByOutput(item('aether_legacy:enchanted_gravitite')) +// mods.aether_legacy.enchanter.removeAll() + +mods.aether_legacy.enchanter.recipeBuilder() + .input(item('minecraft:clay')) + .output(item('minecraft:diamond')) + .time(200) + .register() + + + +// Enchanter Fuel: +// By default, the Enchantar (Altar) takes Ambrosium Shards as fuel. Using GroovyScript, custom fuels can be added. + +mods.aether_legacy.enchanter_fuel.removeByItem(item('aether_legacy:ambrosium_shard')) +// mods.aether_legacy.enchanter_fuel.removeAll() + +mods.aether_legacy.enchanter_fuel.add(item('minecraft:blaze_rod'), 1000) + +// Freezer: +// The Freezer is used to turn certain items into frozen versions. + +mods.aether_legacy.freezer.removeByOutput(item('minecraft:obsidian')) +// mods.aether_legacy.freezer.removeAll() + +mods.aether_legacy.freezer.recipeBuilder() + .input(item('minecraft:clay')) + .output(item('minecraft:dirt')) + .time(200) + .register() + + + +// Freezer: +// By default, the Freezer takes Icestone as fuel. Using GroovyScript, custom fuels can be added. + +mods.aether_legacy.freezer_fuel.removeByItem(item('aether_legacy:icestone')) +// mods.aether_legacy.freezer_fuel.removeAll() + +mods.aether_legacy.freezer_fuel.add(item('minecraft:packed_ice'), 1000) + diff --git a/gradle.properties b/gradle.properties index da7ce1cb1..5133b3b3c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,7 @@ # Debug mod compat debug_actually_additions = false debug_adv_mortars = false +debug_aether = false debug_applied_energistics_2 = false debug_astral = false debug_avaritia = 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 452634f99..b4f56eeb1 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/ModSupport.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/ModSupport.java @@ -6,6 +6,7 @@ import com.cleanroommc.groovyscript.api.IDynamicGroovyProperty; import com.cleanroommc.groovyscript.compat.mods.actuallyadditions.ActuallyAdditions; import com.cleanroommc.groovyscript.compat.mods.advancedmortars.AdvancedMortars; +import com.cleanroommc.groovyscript.compat.mods.aetherlegacy.Aether; import com.cleanroommc.groovyscript.compat.mods.appliedenergistics2.AppliedEnergistics2; import com.cleanroommc.groovyscript.compat.mods.astralsorcery.AstralSorcery; import com.cleanroommc.groovyscript.compat.mods.avaritia.Avaritia; @@ -52,6 +53,7 @@ public class ModSupport implements IDynamicGroovyProperty { public static final GroovyContainer ACTUALLY_ADDITIONS = new InternalModContainer<>("actuallyadditions", "Actually Additions", ActuallyAdditions::new, "aa"); public static final GroovyContainer ADVANCED_MORTARS = new InternalModContainer<>("advancedmortars", "Advanced Mortars", AdvancedMortars::new); + public static final GroovyContainer AETHER = new InternalModContainer<>("aether_legacy", "The Aether", Aether::new, "aether"); public static final GroovyContainer APPLIED_ENERGISTICS_2 = new InternalModContainer<>("appliedenergistics2", "Applied Energistics 2", AppliedEnergistics2::new, "ae2"); public static final GroovyContainer ASTRAL_SORCERY = new InternalModContainer<>("astralsorcery", "Astral Sorcery", AstralSorcery::new, "astral"); public static final GroovyContainer AVARITIA = new InternalModContainer<>("avaritia", "Avaritia", Avaritia::new); diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/aetherlegacy/Accessory.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/aetherlegacy/Accessory.java new file mode 100644 index 000000000..78c78e608 --- /dev/null +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/aetherlegacy/Accessory.java @@ -0,0 +1,94 @@ +package com.cleanroommc.groovyscript.compat.mods.aetherlegacy; + +import com.cleanroommc.groovyscript.api.GroovyLog; +import com.cleanroommc.groovyscript.api.IIngredient; +import com.cleanroommc.groovyscript.api.documentation.annotations.*; +import com.cleanroommc.groovyscript.helper.Alias; +import com.cleanroommc.groovyscript.helper.EnumHelper; +import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; +import com.cleanroommc.groovyscript.registry.ForgeRegistryWrapper; +import com.gildedgames.the_aether.api.accessories.AccessoryType; +import com.gildedgames.the_aether.api.accessories.AetherAccessory; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.common.registry.GameRegistry; +import org.jetbrains.annotations.Nullable; + +import java.util.Arrays; + +@RegistryDescription +public class Accessory extends ForgeRegistryWrapper { + + public Accessory() { + super(GameRegistry.findRegistry(AetherAccessory.class), Alias.generateOfClass(Accessory.class)); + } + + @MethodDescription(type = MethodDescription.Type.ADDITION) + public void add(ItemStack item, String type) { + AccessoryType accessoryType = EnumHelper.valueOfNullable(AccessoryType.class, type, false); + if (accessoryType == null) { + GroovyLog.msg("Error adding Aether accessory") + .add(accessoryType == null, "type with name {} does not exist. Valid values are {}.", type, Arrays.toString(AccessoryType.values())) + .error() + .post(); + return; + } + AetherAccessory accessory = new AetherAccessory(item, accessoryType); + add(accessory); + } + + @MethodDescription(description = "groovyscript.wiki.removeByInput", example = @Example("item('aether_legacy:iron_pendant')")) + public void removeByInput(IIngredient input) { + this.getRegistry().getValuesCollection().forEach(accessory -> { + if (input.test(accessory.getAccessoryStack())) { + remove(accessory); + } + }); + } + + @RecipeBuilderDescription(example = @Example(".input(item('minecraft:shield')).accessoryType('shield')")) + public RecipeBuilder recipeBuilder() { + return new RecipeBuilder(); + } + + @Property(property = "input", valid = @Comp("1")) + public static class RecipeBuilder extends AbstractRecipeBuilder { + + @Property + private AccessoryType accessoryType; + + @RecipeBuilderMethodDescription + public RecipeBuilder accessoryType(String type) { + accessoryType = EnumHelper.valueOfNullable(AccessoryType.class, type, false); + return this; + } + + @RecipeBuilderMethodDescription + public RecipeBuilder accessoryType(AccessoryType type) { + accessoryType = type; + return this; + } + + @Override + public String getErrorMsg() { + return "Error adding Aether Accessory"; + } + + @Override + public void validate(GroovyLog.Msg msg) { + validateItems(msg, 1, 1, 0, 0); + validateFluids(msg); + msg.add(accessoryType == null, "type with name {} does not exist. Valid values are {}.", accessoryType.toString(), Arrays.toString(AccessoryType.values())); + } + + @RecipeBuilderRegistrationMethod + @Override + public @Nullable AetherAccessory register() { + if (!validate()) return null; + + AetherAccessory accessory = new AetherAccessory(input.get(0).getMatchingStacks()[0], accessoryType); + Aether.accessory.add(accessory); + return accessory; + } + } + +} diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/aetherlegacy/Aether.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/aetherlegacy/Aether.java new file mode 100644 index 000000000..f4eac9d8f --- /dev/null +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/aetherlegacy/Aether.java @@ -0,0 +1,21 @@ +package com.cleanroommc.groovyscript.compat.mods.aetherlegacy; + +import com.cleanroommc.groovyscript.compat.mods.ModPropertyContainer; + +public class Aether extends ModPropertyContainer { + + public static final Enchanter enchanter = new Enchanter(); + public static final EnchanterFuel enchanterFuel = new EnchanterFuel(); + public static final Freezer freezer = new Freezer(); + public static final FreezerFuel freezerFuel = new FreezerFuel(); + public static final Accessory accessory = new Accessory(); + + public Aether() { + addRegistry(enchanter); + addRegistry(enchanterFuel); + addRegistry(freezer); + addRegistry(freezerFuel); + addRegistry(accessory); + } + +} diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/aetherlegacy/Enchanter.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/aetherlegacy/Enchanter.java new file mode 100644 index 000000000..9f76a4f89 --- /dev/null +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/aetherlegacy/Enchanter.java @@ -0,0 +1,77 @@ +package com.cleanroommc.groovyscript.compat.mods.aetherlegacy; + +import com.cleanroommc.groovyscript.api.GroovyLog; +import com.cleanroommc.groovyscript.api.IIngredient; +import com.cleanroommc.groovyscript.api.documentation.annotations.*; +import com.cleanroommc.groovyscript.helper.Alias; +import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; +import com.cleanroommc.groovyscript.registry.ForgeRegistryWrapper; +import com.gildedgames.the_aether.api.enchantments.AetherEnchantment; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.common.registry.GameRegistry; +import org.jetbrains.annotations.Nullable; + +@RegistryDescription +public class Enchanter extends ForgeRegistryWrapper { + + public Enchanter() { + super(GameRegistry.findRegistry(AetherEnchantment.class), Alias.generateOfClass(Enchanter.class)); + } + + @RecipeBuilderDescription(example = @Example(".input(item('minecraft:clay')).output(item('minecraft:diamond')).time(200)")) + public RecipeBuilder recipeBuilder() { + return new RecipeBuilder(); + } + + @MethodDescription(type = MethodDescription.Type.ADDITION) + public void add(ItemStack input, ItemStack output, int timeRequired) { + AetherEnchantment enchantment = new AetherEnchantment(input, output, timeRequired); + add(enchantment); + } + + @MethodDescription(description = "groovyscript.wiki.removeByOutput", example = @Example("item('aether_legacy:enchanted_gravitite')")) + public void removeByOutput(IIngredient output) { + this.getRegistry().getValuesCollection().forEach(enchantment -> { + if (output.test(enchantment.getOutput())) { + remove(enchantment); + } + }); + } + + @Property(property = "input", valid = @Comp("1")) + @Property(property = "output", valid = @Comp("1")) + public static class RecipeBuilder extends AbstractRecipeBuilder { + + @Property(valid = @Comp(type = Comp.Type.GTE, value = "0")) + private int time; + + @RecipeBuilderMethodDescription + public RecipeBuilder time(int time) { + this.time = time; + return this; + } + + @Override + public String getErrorMsg() { + return "Error adding Aether Enchanter Recipe"; + } + + @Override + public void validate(GroovyLog.Msg msg) { + validateItems(msg, 1, 1, 1, 1); + validateFluids(msg); + msg.add(time < 0, "time must be a non-negative integer, yet it was {}", time); + } + + @RecipeBuilderRegistrationMethod + @Override + public @Nullable AetherEnchantment register() { + if (!validate()) return null; + + AetherEnchantment enchantment = new AetherEnchantment(input.get(0).getMatchingStacks()[0], output.get(0), time); + Aether.enchanter.add(enchantment); + return enchantment; + } + } + +} diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/aetherlegacy/EnchanterFuel.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/aetherlegacy/EnchanterFuel.java new file mode 100644 index 000000000..3f41a1d11 --- /dev/null +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/aetherlegacy/EnchanterFuel.java @@ -0,0 +1,34 @@ +package com.cleanroommc.groovyscript.compat.mods.aetherlegacy; + +import com.cleanroommc.groovyscript.api.IIngredient; +import com.cleanroommc.groovyscript.api.documentation.annotations.Example; +import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; +import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription; +import com.cleanroommc.groovyscript.helper.Alias; +import com.cleanroommc.groovyscript.registry.ForgeRegistryWrapper; +import com.gildedgames.the_aether.api.enchantments.AetherEnchantmentFuel; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.common.registry.GameRegistry; + +@RegistryDescription +public class EnchanterFuel extends ForgeRegistryWrapper { + + public EnchanterFuel() { + super(GameRegistry.findRegistry(AetherEnchantmentFuel.class), Alias.generateOfClass(EnchanterFuel.class)); + } + + @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("item('minecraft:blaze_rod'), 1000")) + public void add(ItemStack fuel, int timeGiven) { + AetherEnchantmentFuel enchantmentFuel = new AetherEnchantmentFuel(fuel, timeGiven); + add(enchantmentFuel); + } + + @MethodDescription(description = "groovyscript.wiki.removeByInput", example = @Example("item('aether_legacy:ambrosium_shard')")) + public void removeByItem(IIngredient fuel) { + this.getRegistry().getValuesCollection().forEach(enchantmentFuel -> { + if (fuel.test(enchantmentFuel.getFuelStack())) { + remove(enchantmentFuel); + } + }); + } +} diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/aetherlegacy/Freezer.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/aetherlegacy/Freezer.java new file mode 100644 index 000000000..8af5080be --- /dev/null +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/aetherlegacy/Freezer.java @@ -0,0 +1,76 @@ +package com.cleanroommc.groovyscript.compat.mods.aetherlegacy; + +import com.cleanroommc.groovyscript.api.GroovyLog; +import com.cleanroommc.groovyscript.api.IIngredient; +import com.cleanroommc.groovyscript.api.documentation.annotations.*; +import com.cleanroommc.groovyscript.helper.Alias; +import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; +import com.cleanroommc.groovyscript.registry.ForgeRegistryWrapper; +import com.gildedgames.the_aether.api.freezables.AetherFreezable; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.common.registry.GameRegistry; +import org.jetbrains.annotations.Nullable; + +@RegistryDescription +public class Freezer extends ForgeRegistryWrapper { + + public Freezer() { + super(GameRegistry.findRegistry(AetherFreezable.class), Alias.generateOfClass(Freezer.class)); + } + + @RecipeBuilderDescription(example = @Example(".input(item('minecraft:clay')).output(item('minecraft:dirt')).time(200)")) + public RecipeBuilder recipeBuilder() { + return new RecipeBuilder(); + } + + @MethodDescription(type = MethodDescription.Type.ADDITION) + public void add(ItemStack input, ItemStack output, int timeRequired) { + AetherFreezable freezable = new AetherFreezable(input, output, timeRequired); + add(freezable); + } + + @MethodDescription(description = "groovyscript.wiki.removeByOutput", example = @Example("item('minecraft:obsidian')")) + public void removeByOutput(IIngredient output) { + this.getRegistry().getValuesCollection().forEach(freezable -> { + if (output.test(freezable.getOutput())) { + remove(freezable); + } + }); + } + + @Property(property = "input", valid = @Comp("1")) + @Property(property = "output", valid = @Comp("1")) + public static class RecipeBuilder extends AbstractRecipeBuilder { + + @Property(valid = @Comp(type = Comp.Type.GTE, value = "0")) + private int time; + + @RecipeBuilderMethodDescription + public RecipeBuilder time(int time) { + this.time = time; + return this; + } + + @Override + public String getErrorMsg() { + return "Error adding Aether Freezer Recipe"; + } + + @Override + public void validate(GroovyLog.Msg msg) { + validateItems(msg, 1, 1, 1, 1); + validateFluids(msg); + msg.add(time < 0, "time must be a non-negative integer, yet it was {}", time); + } + + @RecipeBuilderRegistrationMethod + @Override + public @Nullable AetherFreezable register() { + if (!validate()) return null; + AetherFreezable freezable = new AetherFreezable(input.get(0).getMatchingStacks()[0], output.get(0), time); + Aether.freezer.add(freezable); + return freezable; + } + } + +} diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/aetherlegacy/FreezerFuel.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/aetherlegacy/FreezerFuel.java new file mode 100644 index 000000000..ce6c5ba38 --- /dev/null +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/aetherlegacy/FreezerFuel.java @@ -0,0 +1,34 @@ +package com.cleanroommc.groovyscript.compat.mods.aetherlegacy; + +import com.cleanroommc.groovyscript.api.IIngredient; +import com.cleanroommc.groovyscript.api.documentation.annotations.Example; +import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; +import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription; +import com.cleanroommc.groovyscript.helper.Alias; +import com.cleanroommc.groovyscript.registry.ForgeRegistryWrapper; +import com.gildedgames.the_aether.api.freezables.AetherFreezableFuel; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.common.registry.GameRegistry; + +@RegistryDescription +public class FreezerFuel extends ForgeRegistryWrapper { + + public FreezerFuel() { + super(GameRegistry.findRegistry(AetherFreezableFuel.class), Alias.generateOfClass(FreezerFuel.class)); + } + + @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("item('minecraft:packed_ice'), 1000")) + public void add(ItemStack fuel, int timeGiven) { + AetherFreezableFuel freezableFuel = new AetherFreezableFuel(fuel, timeGiven); + add(freezableFuel); + } + + @MethodDescription(description = "groovyscript.wiki.removeByInput", example = @Example("item('aether_legacy:icestone')")) + public void removeByItem(IIngredient fuel) { + this.getRegistry().getValuesCollection().forEach(freezableFuel -> { + if (fuel.test(freezableFuel.getFuelStack())) { + remove(freezableFuel); + } + }); + } +} diff --git a/src/main/resources/assets/groovyscript/lang/en_us.lang b/src/main/resources/assets/groovyscript/lang/en_us.lang index 6d0b70f1f..eb409e4fa 100644 --- a/src/main/resources/assets/groovyscript/lang/en_us.lang +++ b/src/main/resources/assets/groovyscript/lang/en_us.lang @@ -145,6 +145,23 @@ groovyscript.wiki.advancedmortars.mortar.duration.value=Sets how many interactio groovyscript.wiki.advancedmortars.mortar.secondaryOutput.value=Sets the additional output itemstack groovyscript.wiki.advancedmortars.mortar.secondaryOutputChance.value=Sets the chance of the additional output itemstack being output +# Aether Legacy +groovyscript.wiki.aether_legacy.enchanter.title=Enchanter +groovyscript.wiki.aether_legacy.enchanter.description=Enchanting is a mechanic used to create new items, as well as repair tools, armor, and weapons, using the Altar block. +groovyscript.wiki.aether_legacy.enchanter.add=Adds an Enchanting recipe in the format `input`, `output`, `time`. +groovyscript.wiki.aether_legacy.enchanter_fuel.title=Enchanter Fuel +groovyscript.wiki.aether_legacy.enchanter_fuel.description=By default, the Enchantar (Altar) takes Ambrosium Shards as fuel. Using GroovyScript, custom fuels can be added. +groovyscript.wiki.aether_legacy.enchanter_fuel.add=Adds an Enchanting fuel in the format `item`, `timeGiven`. +groovyscript.wiki.aether_legacy.freezer.title=Freezer +groovyscript.wiki.aether_legacy.freezer.description=The Freezer is used to turn certain items into frozen versions. +groovyscript.wiki.aether_legacy.freezer.add=Adds a Freezer recipe in the format `input`, `output`, `time`. +groovyscript.wiki.aether_legacy.freezer_fuel.title=Freezer +groovyscript.wiki.aether_legacy.freezer_fuel.description= By default, the Freezer takes Icestone as fuel. Using GroovyScript, custom fuels can be added. +groovyscript.wiki.aether_legacy.freezer_fuel.add=Adds a Freezer fuel in the format `item`, `timeGiven`. +groovyscript.wiki.aether_legacy.accessory.title=Accessory +groovyscript.wiki.aether_legacy.accessory.description=The Aether Accessory system. +groovyscript.wiki.aether_legacy.accessory.add=Adds an Accessory in the format `item`, `type`, where type is one of the following: "Ring", "Pendant", "Cape", "Shield", "Glove", or "Misc". + # Applied Energistics 2 groovyscript.wiki.appliedenergistics2.attunement.title=P2P Attunement groovyscript.wiki.appliedenergistics2.attunement.description=Controls using specific items, any items from a mod, or any items with a Capability to convert a P2P into a specific tunnel type.