Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add String based alternatives to builders that use Aspects #60

Merged
merged 5 commits into from
Jun 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions examples/thaumcraft.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand All @@ -41,22 +41,23 @@ mods.thaumcraft.ArcaneWorkbench.shapedBuilder()
.row(' ')
.row(' ')
.key('S', item('minecraft:pumpkin_seeds'))
.aspect(aspect('terra'))
.aspect('terra')
.vis(5)
.register()

//mods.thaumcraft.Aspect.aspectBuilder()
// .tag('humor')
// .chatColor(14013676)
// .component(aspect('cognito'))
// .component(aspect('perditio'))
// .component('perditio')
// .image(resource('thaumcraft:textures/aspects/humor.png'))
// .register()

mods.thaumcraft.AspectHelper.aspectBuilder()
.object(item('minecraft:stone'))
.stripAspects()
.aspect(aspect('ignis') * 20)
.aspect('ordo', 5)
.register()

mods.thaumcraft.AspectHelper.aspectBuilder()
Expand All @@ -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)
Expand Down Expand Up @@ -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'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ public class AspectBracketHandler implements IBracketHandler<AspectStack> {
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))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down