Skip to content
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
12 changes: 12 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,18 @@ dependencies {
deobfProvided 'curse.maven:blood-magic-224791:2822288'
}

if (project.debug_roots.toBoolean()) {
deobfCompile 'curse.maven:patchouli-306770:3162874'
deobfCompile 'curse.maven:mystical_lib-277064:3483816'
deobfCompile 'curse.maven:mystical_world-282940:3460961'
deobfCompile 'curse.maven:roots-246183:3905074'
} else {
deobfProvided 'curse.maven:patchouli-306770:3162874'
deobfProvided 'curse.maven:mystical_lib-277064:3483816'
deobfProvided 'curse.maven:mystical_world-282940:3460961'
deobfProvided 'curse.maven:roots-246183:3905074'
}

if (project.debug_extended_crafting.toBoolean()) {
deobfCompile 'curse.maven:cucumber-272335:2645867'
deobfCompile 'curse.maven:extended-crafting-nomifactory-edition-398267:3613140'
Expand Down
459 changes: 459 additions & 0 deletions examples/roots.groovy

Large diffs are not rendered by default.

12 changes: 5 additions & 7 deletions examples/thaumcraft.groovy
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import net.minecraft.util.ResourceLocation

mods.thaumcraft.Crucible.removeByOutput(item('minecraft:gunpowder'))

mods.thaumcraft.Crucible.recipeBuilder()
Expand Down Expand Up @@ -52,7 +50,7 @@ mods.thaumcraft.ArcaneWorkbench.shapedBuilder()
// .chatColor(14013676)
// .component(aspect('cognito'))
// .component(aspect('perditio'))
// .image(new ResourceLocation('thaumcraft', 'textures/aspects/humor.png'))
// .image(resource('thaumcraft:textures/aspects/humor.png'))
// .register()

mods.thaumcraft.AspectHelper.aspectBuilder()
Expand Down Expand Up @@ -122,12 +120,12 @@ mods.thaumcraft.SmeltingBonus.removeByOutput(item('minecraft:gold_nugget'))
// .formulaAspect(aspect('ignis') * 5)
// .formulaAspect(aspect('terra') * 5)
// .formulaAspect(aspect('aqua') * 5)
// .icon(new ResourceLocation('thaumcraft', 'textures/aspects/humor.png'))
// .background(new ResourceLocation('thaumcraft', 'textures/gui/gui_research_back_1.jpg'))
// .background2(new ResourceLocation('thaumcraft', 'textures/gui/gui_research_back_over.png'))
// .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'))
// .register()
//
//mods.thaumcraft.Research.addResearchLocation(new ResourceLocation('thaumcraft', 'research/new.json'))
//mods.thaumcraft.Research.addResearchLocation(resource('thaumcraft:research/new.json'))

mods.thaumcraft.Research.addScannable('KNOWLEDGETYPEHUMOR', item('minecraft:pumpkin'))

Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ debug_de = false
debug_ie = false
debug_enderio = false
debug_astral = false
debug_roots = false
debug_blood_magic = false
debug_tinkers = false
debug_extended_crafting = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public static BracketHandler<?> getBracketHandler(String key) {
}

public static void init() {
registerBracketHandler("resource", ResourceLocationBracketHandler.INSTANCE);
registerBracketHandler("ore", s -> s.contains("*") ? OreDictWildcardIngredient.of(s) : new OreDictIngredient(s));
registerBracketHandler("item", ItemBracketHandler.INSTANCE, () -> ItemStack.EMPTY);
registerBracketHandler("liquid", BracketHandlerManager::parseFluidStack);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.cleanroommc.groovyscript.brackets;

import com.cleanroommc.groovyscript.api.IBracketHandler;
import net.minecraft.util.ResourceLocation;

import static com.cleanroommc.groovyscript.brackets.BracketHandlerManager.SPLITTER;

public class ResourceLocationBracketHandler implements IBracketHandler<ResourceLocation> {

public static final ResourceLocationBracketHandler INSTANCE = new ResourceLocationBracketHandler();

private ResourceLocationBracketHandler() {
}

@Override
public ResourceLocation parse(String mainArg, Object[] args) {
String[] parts = mainArg.split(SPLITTER);
if (parts.length > 1) {
return new ResourceLocation(parts[0], parts[1]);
}

if (args.length > 1 || (args.length == 1 && !(args[0] instanceof String))) {
throw new IllegalArgumentException("Arguments not valid for bracket handler. Use 'resource(String)' or 'resource(String mod, String path)'");
}
return new ResourceLocation(mainArg, (String) args[0]);
}

@Override
public ResourceLocation parse(String arg) {
String[] parts = arg.split(SPLITTER);
if (parts.length < 2) {
return null;
}
return new ResourceLocation(parts[0], parts[1]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.cleanroommc.groovyscript.compat.mods.immersiveengineering.ImmersiveEngineering;
import com.cleanroommc.groovyscript.compat.mods.jei.JustEnoughItems;
import com.cleanroommc.groovyscript.compat.mods.mekanism.Mekanism;
import com.cleanroommc.groovyscript.compat.mods.roots.Roots;
import com.cleanroommc.groovyscript.compat.mods.tcomplement.TinkersComplement;
import com.cleanroommc.groovyscript.compat.mods.thaumcraft.Thaumcraft;
import com.cleanroommc.groovyscript.compat.mods.thermalexpansion.ThermalExpansion;
Expand Down Expand Up @@ -45,6 +46,7 @@ public class ModSupport implements IDynamicGroovyProperty {
public static final Container<TinkersConstruct> TINKERS_CONSTRUCT = new Container<>("tconstruct", "Tinkers' Construct", TinkersConstruct::new, "ticon", "tinkersconstruct");
public static final Container<TinkersComplement> TINKERS_COMPLEMENT = new Container<>("tcomplement", "Tinkers Complement", TinkersComplement::new, "tcomp", "tinkerscomplement");
public static final Container<DraconicEvolution> DRACONIC_EVO = new Container<>("draconicevolution", "Draconic Evolution", DraconicEvolution::new, "de");
public static final Container<Roots> ROOTS = new Container<>("roots", "Roots 3", Roots::new);
public static final Container<BloodMagic> BLOOD_MAGIC = new Container<>("bloodmagic", "Blood Magic: Alchemical Wizardry", BloodMagic::new, "bm");
public static final Container<ImmersiveEngineering> IMMERSIVE_ENGINEERING = new Container<>("immersiveengineering", "Immersive Engineering", ImmersiveEngineering::new, "ie");
public static final Container<IC2> INDUSTRIALCRAFT = new Container<>("ic2", "Industrial Craft 2", IC2::new, "industrialcraft");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
package com.cleanroommc.groovyscript.compat.mods.roots;

import com.cleanroommc.groovyscript.api.GroovyLog;
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 epicsquid.roots.recipe.AnimalHarvestRecipe;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.registry.EntityEntry;
import org.apache.commons.lang3.tuple.Pair;
import org.jetbrains.annotations.Nullable;

import java.util.Map;

import static epicsquid.roots.init.ModRecipes.getAnimalHarvestRecipes;
import static epicsquid.roots.init.ModRecipes.removeAnimalHarvestRecipe;

public class AnimalHarvest extends VirtualizedRegistry<Pair<ResourceLocation, AnimalHarvestRecipe>> {

public AnimalHarvest() {
super();
}

public static RecipeBuilder recipeBuilder() {
return new RecipeBuilder();
}

@Override
public void onReload() {
removeScripted().forEach(pair -> removeAnimalHarvestRecipe(pair.getKey()));
restoreFromBackup().forEach(pair -> getAnimalHarvestRecipes().put(pair.getKey(), pair.getValue()));
}

public void add(AnimalHarvestRecipe recipe) {
add(recipe.getRegistryName(), recipe);
}

public void add(ResourceLocation name, AnimalHarvestRecipe recipe) {
getAnimalHarvestRecipes().put(name, recipe);
addScripted(Pair.of(name, recipe));
}

public ResourceLocation findRecipe(AnimalHarvestRecipe recipe) {
for (Map.Entry<ResourceLocation, AnimalHarvestRecipe> entry : getAnimalHarvestRecipes().entrySet()) {
if (entry.getValue().matches(recipe.getHarvestClass())) return entry.getKey();
}
return null;
}

public boolean removeByName(ResourceLocation name) {
AnimalHarvestRecipe recipe = getAnimalHarvestRecipes().get(name);
if (recipe == null) return false;
removeAnimalHarvestRecipe(name);
addBackup(Pair.of(name, recipe));
return true;
}

public boolean removeByEntity(EntityEntry entity) {
for (Map.Entry<ResourceLocation, AnimalHarvestRecipe> x : getAnimalHarvestRecipes().entrySet()) {
if (x.getValue().matches(entity.getEntityClass())) {
getAnimalHarvestRecipes().remove(x.getKey());
addBackup(Pair.of(x.getKey(), x.getValue()));
return true;
}
}
return false;
}

public void removeAll() {
getAnimalHarvestRecipes().forEach((key, value) -> addBackup(Pair.of(key, value)));
getAnimalHarvestRecipes().clear();
}

public SimpleObjectStream<Map.Entry<ResourceLocation, AnimalHarvestRecipe>> streamRecipes() {
return new SimpleObjectStream<>(getAnimalHarvestRecipes().entrySet())
.setRemover(r -> this.removeByName(r.getKey()));
}

public static class RecipeBuilder extends AbstractRecipeBuilder<AnimalHarvestRecipe> {

private Class<? extends EntityLivingBase> entity;

public RecipeBuilder entity(EntityEntry entity) {
this.entity = (Class<? extends EntityLivingBase>) entity.getEntityClass();
return this;
}

@Override
public String getErrorMsg() {
return "Error adding Roots Animal Harvest recipe";
}

public String getRecipeNamePrefix() {
return "groovyscript_animal_harvest_";
}

@Override
public void validate(GroovyLog.Msg msg) {
validateName();
validateItems(msg);
validateFluids(msg);
msg.add(entity == null, "entity must be defined and extended EntityLivingBase, instead it was {}", entity);
}

@Override
public @Nullable AnimalHarvestRecipe register() {
if (!validate()) return null;
AnimalHarvestRecipe recipe = new AnimalHarvestRecipe(name, entity);
ModSupport.ROOTS.get().animalHarvest.add(name, recipe);
return recipe;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
package com.cleanroommc.groovyscript.compat.mods.roots;

import com.cleanroommc.groovyscript.api.GroovyLog;
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 epicsquid.roots.recipe.AnimalHarvestFishRecipe;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import org.apache.commons.lang3.tuple.Pair;
import org.jetbrains.annotations.Nullable;

import java.util.Map;

import static epicsquid.roots.init.ModRecipes.getAnimalHarvestFishRecipes;
import static epicsquid.roots.init.ModRecipes.removeAnimalHarvestFishRecipe;


public class AnimalHarvestFish extends VirtualizedRegistry<Pair<ResourceLocation, AnimalHarvestFishRecipe>> {

public AnimalHarvestFish() {
super();
}

public static RecipeBuilder recipeBuilder() {
return new RecipeBuilder();
}

@Override
public void onReload() {
removeScripted().forEach(pair -> removeAnimalHarvestFishRecipe(pair.getKey()));
restoreFromBackup().forEach(pair -> getAnimalHarvestFishRecipes().put(pair.getKey(), pair.getValue()));
}

public void add(AnimalHarvestFishRecipe recipe) {
add(recipe.getRegistryName(), recipe);
}

public void add(ResourceLocation name, AnimalHarvestFishRecipe recipe) {
getAnimalHarvestFishRecipes().put(name, recipe);
addScripted(Pair.of(name, recipe));
}

public ResourceLocation findRecipeByOutput(ItemStack output) {
for (Map.Entry<ResourceLocation, AnimalHarvestFishRecipe> entry : getAnimalHarvestFishRecipes().entrySet()) {
if (ItemStack.areItemsEqual(entry.getValue().getItemStack(), output)) return entry.getKey();
}
return null;
}

public boolean removeByName(ResourceLocation name) {
AnimalHarvestFishRecipe recipe = getAnimalHarvestFishRecipes().get(name);
if (recipe == null) return false;
removeAnimalHarvestFishRecipe(name);
addBackup(Pair.of(name, recipe));
return true;
}

public boolean removeByOutput(ItemStack output) {
for (Map.Entry<ResourceLocation, AnimalHarvestFishRecipe> x : getAnimalHarvestFishRecipes().entrySet()) {
if (ItemStack.areItemsEqual(x.getValue().getItemStack(), output)) {
getAnimalHarvestFishRecipes().remove(x.getKey());
addBackup(Pair.of(x.getKey(), x.getValue()));
return true;
}
}
return false;
}

public boolean removeByFish(ItemStack fish) {
return removeByOutput(fish);
}

public void removeAll() {
getAnimalHarvestFishRecipes().forEach((key, value) -> addBackup(Pair.of(key, value)));
getAnimalHarvestFishRecipes().clear();
}

public SimpleObjectStream<Map.Entry<ResourceLocation, AnimalHarvestFishRecipe>> streamRecipes() {
return new SimpleObjectStream<>(getAnimalHarvestFishRecipes().entrySet())
.setRemover(r -> this.removeByName(r.getKey()));
}

public static class RecipeBuilder extends AbstractRecipeBuilder<AnimalHarvestFishRecipe> {

private int weight;

public RecipeBuilder weight(int weight) {
this.weight = weight;
return this;
}

public RecipeBuilder fish(ItemStack fish) {
this.output.add(fish);
return this;
}

@Override
public String getErrorMsg() {
return "Error adding Roots Animal Harvest Fish recipe";
}

public String getRecipeNamePrefix() {
return "groovyscript_animal_harvest_fish_";
}

@Override
public void validate(GroovyLog.Msg msg) {
validateName();
validateItems(msg, 0, 0, 1, 1);
validateFluids(msg);
msg.add(weight <= 0, "weight must be a nonnegative integer greater than 0, instead it was {}", weight);
}

@Override
public @Nullable AnimalHarvestFishRecipe register() {
if (!validate()) return null;
AnimalHarvestFishRecipe recipe = new AnimalHarvestFishRecipe(name, output.get(0), weight);
ModSupport.ROOTS.get().animalHarvestFish.add(name, recipe);
return recipe;
}
}
}
Loading