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
10 changes: 10 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,17 @@ dependencies {
runtimeOnly rfg.deobf('curse.maven:guide-api-228832:2645992')
runtimeOnly rfg.deobf('curse.maven:blood-magic-224791:2822288')
}

compileOnly rfg.deobf('curse.maven:cyclops-core-232758:3159497')
if (project.debug_evilcraft.toBoolean()) {
runtimeOnly rfg.deobf('curse.maven:cyclops-core-232758:3159497')
}

compileOnly rfg.deobf('curse.maven:evilcraft-74610:2811267')
if (project.debug_evilcraft.toBoolean()) {
runtimeOnly rfg.deobf('curse.maven:evilcraft-74610:2811267')
}

compileOnly rfg.deobf('curse.maven:actually-additions-228404:3117927')
if (project.debug_actually_additions.toBoolean()) {
runtimeOnly rfg.deobf('curse.maven:actually-additions-228404:3117927')
Expand Down
70 changes: 70 additions & 0 deletions examples/evilcraft.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@

// Weather Bracket Handler
weather('clear')
weather('rain')
weather('lightning')


// Blood Infuser:
// Consumes an item, some fluid, and requires a given tier of Promise of Tenacity to produce the output and some experience after a duration.
mods.evilcraft.bloodinfuser.recipeBuilder()
.input(item('minecraft:clay'))
.output(item('minecraft:clay'))
.fluidInput(fluid('evilcraftblood') * 1000)
.tier(3) // Optional integer. Requires at least this tier of Promise of Tenacity to craft. Defaults to 0.
.duration(100) // Optional integer. Time in ticks for the recipe to complete. Defaults to 0.
.xp(10000) // Optional float. Experience gained when completing the recipe. Defaults to 0.
.register()

mods.evilcraft.bloodinfuser.recipeBuilder()
.input(item('minecraft:gold_ingot'))
.output(item('minecraft:clay'))
.fluidInput(100000) // Calling `fluidInput` with just an integer will automatically consider the fluid as "evilcraftblood".
.register()

mods.evilcraft.bloodinfuser.recipeBuilder()
.input(item('minecraft:diamond'))
.output(item('minecraft:clay') * 4)
.fluidInput(5000) // `blood` can also be used as an alias for `fluidInput` when only an integer is used.
.tier(1)
.register()

mods.evilcraft.bloodinfuser.removeByInput(item('evilcraft:dark_gem'))
mods.evilcraft.bloodinfuser.removeByOutput(item('minecraft:leather'))
//mods.evilcraft.bloodinfuser.removeAll()


// Environmental Accumulator:
// Consumes an item to give an output, possibly changing the weather. Has a cooldown time or a blood cost.
mods.evilcraft.environmentalaccumulator.recipeBuilder()
.input(item('minecraft:clay'))
.output(item('minecraft:clay') * 2)
.inputWeather(weather('clear'))
.outputWeather(weather('rain'))
.processingspeed(1) // Optional doube. Controls the visual rotation of the item while crafting. Defaults to the amount set in the config.
.cooldowntime(1000) // Optional integer. Time it takes before another recipe can be run. Defaults to the time set in the config.
// cooldowntime also controls the amount of evilcraftblood consumed by the Sanguinary Environmental Accumulator
.duration(10) // Optional integer. Time it takes to complete the recipe. Defaults to the time set in the config.
.register()

mods.evilcraft.environmentalaccumulator.recipeBuilder()
.input(item('minecraft:gold_ingot'))
.output(item('minecraft:diamond'))
.inputWeather(weather('rain'))
.outputWeather(weather('lightning'))
.speed(10) // Short for processingspeed.
.cooldown(1) // Short for cooldowntime.
.register()

mods.evilcraft.environmentalaccumulator.recipeBuilder()
.input(item('minecraft:diamond'))
.output(item('minecraft:clay') * 16)
.inputWeather(weather('lightning'))
.outputWeather(weather('lightning'))
.register()


mods.evilcraft.environmentalaccumulator.removeByInput(item('evilcraft:exalted_crafter:1'))
mods.evilcraft.environmentalaccumulator.removeByOutput(item('evilcraft:exalted_crafter:2'))
//mods.evilcraft.environmentalaccumulator.removeAll()

1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ coremod_plugin_class_name = com.cleanroommc.groovyscript.core.GroovyScriptCore
debug_actually_additions = false
debug_chisel = false
debug_mekanism = false
debug_evilcraft = false
debug_thermal = false
debug_thaum = false
debug_ic2 = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.cleanroommc.groovyscript.compat.mods.chisel.Chisel;
import com.cleanroommc.groovyscript.compat.mods.draconicevolution.DraconicEvolution;
import com.cleanroommc.groovyscript.compat.mods.enderio.EnderIO;
import com.cleanroommc.groovyscript.compat.mods.evilcraft.EvilCraft;
import com.cleanroommc.groovyscript.compat.mods.extendedcrafting.ExtendedCrafting;
import com.cleanroommc.groovyscript.compat.mods.forestry.Forestry;
import com.cleanroommc.groovyscript.compat.mods.ic2.IC2;
Expand Down Expand Up @@ -53,6 +54,7 @@ public class ModSupport implements IDynamicGroovyProperty {
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<EvilCraft> EVILCRAFT = new Container<>("evilcraft", "EvilCraft", EvilCraft::new);
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");
public static final Container<ExtendedCrafting> EXTENDED_CRAFTING = new Container<>("extendedcrafting", "Extended Crafting", ExtendedCrafting::new);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
package com.cleanroommc.groovyscript.compat.mods.evilcraft;

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 net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import org.cyclops.cyclopscore.recipe.custom.api.IRecipe;
import org.cyclops.cyclopscore.recipe.custom.component.IngredientRecipeComponent;
import org.cyclops.evilcraft.core.recipe.custom.DurationXpRecipeProperties;
import org.cyclops.evilcraft.core.recipe.custom.IngredientFluidStackAndTierRecipeComponent;
import org.jetbrains.annotations.Nullable;

public class BloodInfuser extends VirtualizedRegistry<IRecipe<IngredientFluidStackAndTierRecipeComponent, IngredientRecipeComponent, DurationXpRecipeProperties>> {

public BloodInfuser() {
super();
}

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

@Override
public void onReload() {
removeScripted().forEach(org.cyclops.evilcraft.block.BloodInfuser.getInstance().getRecipeRegistry().allRecipes()::remove);
restoreFromBackup().forEach(org.cyclops.evilcraft.block.BloodInfuser.getInstance().getRecipeRegistry().allRecipes()::add);
}

public void add(IRecipe<IngredientFluidStackAndTierRecipeComponent, IngredientRecipeComponent, DurationXpRecipeProperties> recipe) {
this.add(recipe, true);
}

public void add(IRecipe<IngredientFluidStackAndTierRecipeComponent, IngredientRecipeComponent, DurationXpRecipeProperties> recipe, boolean add) {
if (recipe == null) return;
addScripted(recipe);
if (add) org.cyclops.evilcraft.block.BloodInfuser.getInstance().getRecipeRegistry().allRecipes().add(recipe);
}

public boolean remove(IRecipe<IngredientFluidStackAndTierRecipeComponent, IngredientRecipeComponent, DurationXpRecipeProperties> recipe) {
if (recipe == null) return false;
addBackup(recipe);
org.cyclops.evilcraft.block.BloodInfuser.getInstance().getRecipeRegistry().allRecipes().remove(recipe);
return true;
}

public boolean removeByInput(ItemStack input) {
return org.cyclops.evilcraft.block.BloodInfuser.getInstance().getRecipeRegistry().allRecipes().removeIf(r -> {
if (r.getInput().getIngredient().test(input)) {
addBackup(r);
return true;
}
return false;
});
}

public boolean removeByOutput(ItemStack input) {
return org.cyclops.evilcraft.block.BloodInfuser.getInstance().getRecipeRegistry().allRecipes().removeIf(r -> {
if (r.getOutput().getIngredient().test(input)) {
addBackup(r);
return true;
}
return false;
});
}

public void removeAll() {
org.cyclops.evilcraft.block.BloodInfuser.getInstance().getRecipeRegistry().allRecipes().forEach(this::addBackup);
org.cyclops.evilcraft.block.BloodInfuser.getInstance().getRecipeRegistry().allRecipes().clear();
}

public SimpleObjectStream<IRecipe<IngredientFluidStackAndTierRecipeComponent, IngredientRecipeComponent, DurationXpRecipeProperties>> streamRecipes() {
return new SimpleObjectStream<>(org.cyclops.evilcraft.block.BloodInfuser.getInstance().getRecipeRegistry().allRecipes())
.setRemover(this::remove);
}

public static class RecipeBuilder extends AbstractRecipeBuilder<IRecipe<IngredientFluidStackAndTierRecipeComponent, IngredientRecipeComponent, DurationXpRecipeProperties>> {

private static final Fluid bloodFluid = FluidRegistry.getFluid("evilcraftblood");

private int tier = 0;
private int duration = 0;
private float xp = 0;

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

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

public RecipeBuilder xp(float xp) {
this.xp = xp;
return this;
}

public RecipeBuilder blood(int amount) {
this.fluidInput.add(new FluidStack(bloodFluid, amount));
return this;
}

public RecipeBuilder fluidInput(int amount) {
this.fluidInput.add(new FluidStack(bloodFluid, amount));
return this;
}

@Override
public String getErrorMsg() {
return "Error adding EvilCraft Blood Infuser Recipe";
}

@Override
public void validate(GroovyLog.Msg msg) {
validateItems(msg, 1, 1, 1, 1);
validateFluids(msg, 1, 1, 0, 0);
msg.add(tier < 0 || tier > 3, "tier must be between 0 and 3, yet it was {}", tier);
msg.add(duration < 0, "duration must be a non negative integer, yet it was {}", duration);
msg.add(xp < 0, "xp must be a non negative integer, yet it was {}", xp);
}

@Override
public @Nullable IRecipe<IngredientFluidStackAndTierRecipeComponent, IngredientRecipeComponent, DurationXpRecipeProperties> register() {
if (!validate()) return null;
IRecipe<IngredientFluidStackAndTierRecipeComponent, IngredientRecipeComponent, DurationXpRecipeProperties> recipe =
org.cyclops.evilcraft.block.BloodInfuser.getInstance().getRecipeRegistry().registerRecipe(
new IngredientFluidStackAndTierRecipeComponent(input.get(0).toMcIngredient(), fluidInput.get(0), tier),
new IngredientRecipeComponent(output.get(0)),
new DurationXpRecipeProperties(duration, xp)
);
ModSupport.EVILCRAFT.get().bloodInfuser.add(recipe, false);
return recipe;
}
}
}
Loading