diff --git a/examples/thaumcraft.groovy b/examples/thaumcraft.groovy index 9fd24f9ea..9ba5460fe 100644 --- a/examples/thaumcraft.groovy +++ b/examples/thaumcraft.groovy @@ -14,7 +14,7 @@ mods.thaumcraft.InfusionCrafting.recipeBuilder() .mainInput(item('minecraft:gunpowder')) .output(item('minecraft:gold_ingot')) .aspect(aspect('terra') * 20) - .aspect(aspect('ignis') * 30) + .aspect('ignis', 30) .input(crystal('aer')) .input(crystal('ignis')) .input(crystal('aqua')) @@ -41,7 +41,7 @@ mods.thaumcraft.ArcaneWorkbench.shapedBuilder() .row(' ') .row(' ') .key('S', item('minecraft:pumpkin_seeds')) - .aspect(aspect('terra')) + .aspect('terra') .vis(5) .register() @@ -49,7 +49,7 @@ mods.thaumcraft.ArcaneWorkbench.shapedBuilder() // .tag('humor') // .chatColor(14013676) // .component(aspect('cognito')) -// .component(aspect('perditio')) +// .component('perditio') // .image(resource('thaumcraft:textures/aspects/humor.png')) // .register() @@ -57,6 +57,7 @@ mods.thaumcraft.AspectHelper.aspectBuilder() .object(item('minecraft:stone')) .stripAspects() .aspect(aspect('ignis') * 20) + .aspect('ordo', 5) .register() mods.thaumcraft.AspectHelper.aspectBuilder() @@ -68,7 +69,7 @@ mods.thaumcraft.AspectHelper.aspectBuilder() mods.thaumcraft.AspectHelper.aspectBuilder() .entity(entity('minecraft:chicken')) .stripAspects() - .aspect(aspect('bestia') * 20) + .aspect('bestia', 20) .register() mods.thaumcraft.Warp.addWarp(item('minecraft:pumpkin'), 3) @@ -116,10 +117,10 @@ mods.thaumcraft.SmeltingBonus.removeByOutput(item('minecraft:gold_nugget')) // .formulaAspect(aspect('herba') * 5) // .formulaAspect(aspect('ordo') * 5) // .formulaAspect(aspect('perditio') * 5) -// .formulaAspect(aspect('aer') * 5) -// .formulaAspect(aspect('ignis') * 5) +// .formulaAspect('aer', 5) +// .formulaAspect('ignis', 5) // .formulaAspect(aspect('terra') * 5) -// .formulaAspect(aspect('aqua') * 5) +// .formulaAspect('aqua', 5) // .icon(resource('thaumcraft:textures/aspects/humor.png')) // .background(resource('thaumcraft:textures/gui/gui_research_back_1.jpg')) // .background2(resource('thaumcraft:textures/gui/gui_research_back_over.png')) diff --git a/src/main/java/com/cleanroommc/groovyscript/brackets/AspectBracketHandler.java b/src/main/java/com/cleanroommc/groovyscript/brackets/AspectBracketHandler.java index fa326843a..14580e8ac 100644 --- a/src/main/java/com/cleanroommc/groovyscript/brackets/AspectBracketHandler.java +++ b/src/main/java/com/cleanroommc/groovyscript/brackets/AspectBracketHandler.java @@ -12,6 +12,12 @@ public class AspectBracketHandler implements IBracketHandler { private AspectBracketHandler() { } + public static Aspect validateAspect(String tag) { + Aspect aspect = Aspect.getAspect(tag); + if (aspect == null) GroovyLog.msg("Can't find aspect for name {}!", tag).error().post(); + return aspect; + } + @Override public AspectStack parse(String mainArg, Object[] args) { if (args.length > 1 || (args.length == 1 && !(args[0] instanceof Integer))) { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/Crucible.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/Crucible.java index d78580eb9..bd274f49f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/Crucible.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/Crucible.java @@ -3,6 +3,7 @@ import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; +import com.cleanroommc.groovyscript.brackets.AspectBracketHandler; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.compat.mods.thaumcraft.aspect.AspectStack; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; @@ -13,6 +14,7 @@ import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; import thaumcraft.api.ThaumcraftApi; +import thaumcraft.api.aspects.Aspect; import thaumcraft.api.aspects.AspectList; import thaumcraft.api.crafting.CrucibleRecipe; import thaumcraft.api.crafting.IThaumcraftRecipe; @@ -122,6 +124,12 @@ public RecipeBuilder aspect(AspectStack aspectIn) { return this; } + public RecipeBuilder aspect(String tag, int amount) { + Aspect a = AspectBracketHandler.validateAspect(tag); + if (a != null) this.aspects.add(a, amount); + return this; + } + public RecipeBuilder catalyst(IIngredient catalyst) { this.catalyst = catalyst; return this; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/InfusionCrafting.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/InfusionCrafting.java index 72d95dce3..22d95c8e7 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/InfusionCrafting.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/InfusionCrafting.java @@ -3,6 +3,7 @@ import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; +import com.cleanroommc.groovyscript.brackets.AspectBracketHandler; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.compat.mods.thaumcraft.aspect.AspectStack; import com.cleanroommc.groovyscript.helper.ArrayUtils; @@ -16,6 +17,7 @@ import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; import thaumcraft.api.ThaumcraftApi; +import thaumcraft.api.aspects.Aspect; import thaumcraft.api.aspects.AspectList; import thaumcraft.api.crafting.IThaumcraftRecipe; import thaumcraft.api.crafting.InfusionRecipe; @@ -149,6 +151,12 @@ public RecipeBuilder aspect(AspectStack aspect) { return this; } + public RecipeBuilder aspect(String tag, int amount) { + Aspect a = AspectBracketHandler.validateAspect(tag); + if (a != null) this.aspects.add(a, amount); + return this; + } + public RecipeBuilder instability(int instability) { this.instability = instability; return this; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/Research.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/Research.java index 9a5fcccee..befd89b40 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/Research.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/Research.java @@ -1,5 +1,6 @@ package com.cleanroommc.groovyscript.compat.mods.thaumcraft; +import com.cleanroommc.groovyscript.brackets.AspectBracketHandler; import com.cleanroommc.groovyscript.compat.mods.thaumcraft.aspect.AspectStack; import net.minecraft.block.Block; import net.minecraft.block.material.Material; @@ -8,6 +9,7 @@ import net.minecraft.potion.Potion; import net.minecraft.util.ResourceLocation; import thaumcraft.api.ThaumcraftApi; +import thaumcraft.api.aspects.Aspect; import thaumcraft.api.aspects.AspectList; import thaumcraft.api.research.*; import thaumcraft.common.lib.research.ResearchManager; @@ -106,6 +108,12 @@ public ResearchCategoryBuilder formulaAspect(AspectStack aspect) { return this; } + public ResearchCategoryBuilder formulaAspect(String tag, int amount) { + Aspect a = AspectBracketHandler.validateAspect(tag); + if (a != null) this.formula.add(a, amount); + return this; + } + public ResearchCategoryBuilder icon(String icon) { this.icon = new ResourceLocation(icon); return this; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/arcane/ArcaneRecipeBuilder.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/arcane/ArcaneRecipeBuilder.java index 84ea07229..0a1a652b5 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/arcane/ArcaneRecipeBuilder.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/arcane/ArcaneRecipeBuilder.java @@ -2,6 +2,7 @@ import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; +import com.cleanroommc.groovyscript.brackets.AspectBracketHandler; import com.cleanroommc.groovyscript.compat.mods.thaumcraft.aspect.AspectStack; import com.cleanroommc.groovyscript.compat.vanilla.CraftingRecipeBuilder; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; @@ -11,6 +12,7 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.common.registry.ForgeRegistries; import org.apache.commons.lang3.ArrayUtils; +import thaumcraft.api.aspects.Aspect; import thaumcraft.api.aspects.AspectList; import java.util.ArrayList; @@ -37,6 +39,12 @@ public ArcaneRecipeBuilder aspect(AspectStack aspect) { return this; } + public ArcaneRecipeBuilder aspect(String tag, int amount) { + Aspect a = AspectBracketHandler.validateAspect(tag); + if (a != null) this.aspects.add(a, amount); + return this; + } + public ArcaneRecipeBuilder vis(int vis) { this.vis = vis; return this; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/aspect/Aspect.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/aspect/Aspect.java index 57d752374..03af6c79d 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/aspect/Aspect.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/aspect/Aspect.java @@ -1,6 +1,7 @@ package com.cleanroommc.groovyscript.compat.mods.thaumcraft.aspect; import com.cleanroommc.groovyscript.api.GroovyLog; +import com.cleanroommc.groovyscript.brackets.AspectBracketHandler; import net.minecraft.util.ResourceLocation; import thaumcraft.api.aspects.AspectList; @@ -33,6 +34,12 @@ public AspectBuilder component(AspectStack component) { return this; } + public AspectBuilder component(String tag, int amount) { + thaumcraft.api.aspects.Aspect a = AspectBracketHandler.validateAspect(tag); + if (a != null) this.components.add(a, amount); + return this; + } + public AspectBuilder image(String image) { this.image = new ResourceLocation(image); return this; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/aspect/AspectHelper.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/aspect/AspectHelper.java index 663503a80..9fba8cb3a 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/aspect/AspectHelper.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/thaumcraft/aspect/AspectHelper.java @@ -3,12 +3,12 @@ import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; +import com.cleanroommc.groovyscript.brackets.AspectBracketHandler; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; import net.minecraft.item.ItemStack; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.registry.EntityEntry; import org.jetbrains.annotations.ApiStatus; import thaumcraft.api.ThaumcraftApi; @@ -308,6 +308,12 @@ public AspectHelperBuilder aspect(AspectStack aspect) { return this; } + public AspectHelperBuilder aspect(String tag, int amount) { + Aspect a = AspectBracketHandler.validateAspect(tag); + if (a != null) this.aspects.add(new AspectStack(a, amount)); + return this; + } + public AspectHelperBuilder stripAspects() { if (entity != null) { ModSupport.THAUMCRAFT.get().aspectHelper.removeAll(entity);