Skip to content

Commit 339ddfa

Browse files
authored
EvilCraft compat (#58)
* add EvilCraft compat * add compat examples * fix an extra space in item input checks * fix typo * case EnvironmentalAccumulator weather I/O to match bracket handler * address review --------- Co-authored-by: brachy84
1 parent 6ab62b5 commit 339ddfa

File tree

8 files changed

+411
-1
lines changed

8 files changed

+411
-1
lines changed

build.gradle

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,17 @@ dependencies {
131131
runtimeOnly rfg.deobf('curse.maven:guide-api-228832:2645992')
132132
runtimeOnly rfg.deobf('curse.maven:blood-magic-224791:2822288')
133133
}
134+
135+
compileOnly rfg.deobf('curse.maven:cyclops-core-232758:3159497')
136+
if (project.debug_evilcraft.toBoolean()) {
137+
runtimeOnly rfg.deobf('curse.maven:cyclops-core-232758:3159497')
138+
}
134139

140+
compileOnly rfg.deobf('curse.maven:evilcraft-74610:2811267')
141+
if (project.debug_evilcraft.toBoolean()) {
142+
runtimeOnly rfg.deobf('curse.maven:evilcraft-74610:2811267')
143+
}
144+
135145
compileOnly rfg.deobf('curse.maven:actually-additions-228404:3117927')
136146
if (project.debug_actually_additions.toBoolean()) {
137147
runtimeOnly rfg.deobf('curse.maven:actually-additions-228404:3117927')

examples/evilcraft.groovy

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
2+
// Weather Bracket Handler
3+
weather('clear')
4+
weather('rain')
5+
weather('lightning')
6+
7+
8+
// Blood Infuser:
9+
// Consumes an item, some fluid, and requires a given tier of Promise of Tenacity to produce the output and some experience after a duration.
10+
mods.evilcraft.bloodinfuser.recipeBuilder()
11+
.input(item('minecraft:clay'))
12+
.output(item('minecraft:clay'))
13+
.fluidInput(fluid('evilcraftblood') * 1000)
14+
.tier(3) // Optional integer. Requires at least this tier of Promise of Tenacity to craft. Defaults to 0.
15+
.duration(100) // Optional integer. Time in ticks for the recipe to complete. Defaults to 0.
16+
.xp(10000) // Optional float. Experience gained when completing the recipe. Defaults to 0.
17+
.register()
18+
19+
mods.evilcraft.bloodinfuser.recipeBuilder()
20+
.input(item('minecraft:gold_ingot'))
21+
.output(item('minecraft:clay'))
22+
.fluidInput(100000) // Calling `fluidInput` with just an integer will automatically consider the fluid as "evilcraftblood".
23+
.register()
24+
25+
mods.evilcraft.bloodinfuser.recipeBuilder()
26+
.input(item('minecraft:diamond'))
27+
.output(item('minecraft:clay') * 4)
28+
.fluidInput(5000) // `blood` can also be used as an alias for `fluidInput` when only an integer is used.
29+
.tier(1)
30+
.register()
31+
32+
mods.evilcraft.bloodinfuser.removeByInput(item('evilcraft:dark_gem'))
33+
mods.evilcraft.bloodinfuser.removeByOutput(item('minecraft:leather'))
34+
//mods.evilcraft.bloodinfuser.removeAll()
35+
36+
37+
// Environmental Accumulator:
38+
// Consumes an item to give an output, possibly changing the weather. Has a cooldown time or a blood cost.
39+
mods.evilcraft.environmentalaccumulator.recipeBuilder()
40+
.input(item('minecraft:clay'))
41+
.output(item('minecraft:clay') * 2)
42+
.inputWeather(weather('clear'))
43+
.outputWeather(weather('rain'))
44+
.processingspeed(1) // Optional doube. Controls the visual rotation of the item while crafting. Defaults to the amount set in the config.
45+
.cooldowntime(1000) // Optional integer. Time it takes before another recipe can be run. Defaults to the time set in the config.
46+
// cooldowntime also controls the amount of evilcraftblood consumed by the Sanguinary Environmental Accumulator
47+
.duration(10) // Optional integer. Time it takes to complete the recipe. Defaults to the time set in the config.
48+
.register()
49+
50+
mods.evilcraft.environmentalaccumulator.recipeBuilder()
51+
.input(item('minecraft:gold_ingot'))
52+
.output(item('minecraft:diamond'))
53+
.inputWeather(weather('rain'))
54+
.outputWeather(weather('lightning'))
55+
.speed(10) // Short for processingspeed.
56+
.cooldown(1) // Short for cooldowntime.
57+
.register()
58+
59+
mods.evilcraft.environmentalaccumulator.recipeBuilder()
60+
.input(item('minecraft:diamond'))
61+
.output(item('minecraft:clay') * 16)
62+
.inputWeather(weather('lightning'))
63+
.outputWeather(weather('lightning'))
64+
.register()
65+
66+
67+
mods.evilcraft.environmentalaccumulator.removeByInput(item('evilcraft:exalted_crafter:1'))
68+
mods.evilcraft.environmentalaccumulator.removeByOutput(item('evilcraft:exalted_crafter:2'))
69+
//mods.evilcraft.environmentalaccumulator.removeAll()
70+

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ coremod_plugin_class_name = com.cleanroommc.groovyscript.core.GroovyScriptCore
1919
debug_actually_additions = false
2020
debug_chisel = false
2121
debug_mekanism = false
22+
debug_evilcraft = false
2223
debug_thermal = false
2324
debug_thaum = false
2425
debug_ic2 = false

src/main/java/com/cleanroommc/groovyscript/compat/mods/ModSupport.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.cleanroommc.groovyscript.compat.mods.chisel.Chisel;
1010
import com.cleanroommc.groovyscript.compat.mods.draconicevolution.DraconicEvolution;
1111
import com.cleanroommc.groovyscript.compat.mods.enderio.EnderIO;
12+
import com.cleanroommc.groovyscript.compat.mods.evilcraft.EvilCraft;
1213
import com.cleanroommc.groovyscript.compat.mods.extendedcrafting.ExtendedCrafting;
1314
import com.cleanroommc.groovyscript.compat.mods.forestry.Forestry;
1415
import com.cleanroommc.groovyscript.compat.mods.ic2.IC2;
@@ -53,6 +54,7 @@ public class ModSupport implements IDynamicGroovyProperty {
5354
public static final Container<DraconicEvolution> DRACONIC_EVO = new Container<>("draconicevolution", "Draconic Evolution", DraconicEvolution::new, "de");
5455
public static final Container<Roots> ROOTS = new Container<>("roots", "Roots 3", Roots::new);
5556
public static final Container<BloodMagic> BLOOD_MAGIC = new Container<>("bloodmagic", "Blood Magic: Alchemical Wizardry", BloodMagic::new, "bm");
57+
public static final Container<EvilCraft> EVILCRAFT = new Container<>("evilcraft", "EvilCraft", EvilCraft::new);
5658
public static final Container<ImmersiveEngineering> IMMERSIVE_ENGINEERING = new Container<>("immersiveengineering", "Immersive Engineering", ImmersiveEngineering::new, "ie");
5759
public static final Container<IC2> INDUSTRIALCRAFT = new Container<>("ic2", "Industrial Craft 2", IC2::new, "industrialcraft");
5860
public static final Container<ExtendedCrafting> EXTENDED_CRAFTING = new Container<>("extendedcrafting", "Extended Crafting", ExtendedCrafting::new);
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
package com.cleanroommc.groovyscript.compat.mods.evilcraft;
2+
3+
import com.cleanroommc.groovyscript.api.GroovyLog;
4+
import com.cleanroommc.groovyscript.compat.mods.ModSupport;
5+
import com.cleanroommc.groovyscript.helper.SimpleObjectStream;
6+
import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder;
7+
import com.cleanroommc.groovyscript.registry.VirtualizedRegistry;
8+
import net.minecraft.item.ItemStack;
9+
import net.minecraftforge.fluids.Fluid;
10+
import net.minecraftforge.fluids.FluidRegistry;
11+
import net.minecraftforge.fluids.FluidStack;
12+
import org.cyclops.cyclopscore.recipe.custom.api.IRecipe;
13+
import org.cyclops.cyclopscore.recipe.custom.component.IngredientRecipeComponent;
14+
import org.cyclops.evilcraft.core.recipe.custom.DurationXpRecipeProperties;
15+
import org.cyclops.evilcraft.core.recipe.custom.IngredientFluidStackAndTierRecipeComponent;
16+
import org.jetbrains.annotations.Nullable;
17+
18+
public class BloodInfuser extends VirtualizedRegistry<IRecipe<IngredientFluidStackAndTierRecipeComponent, IngredientRecipeComponent, DurationXpRecipeProperties>> {
19+
20+
public BloodInfuser() {
21+
super();
22+
}
23+
24+
public RecipeBuilder recipeBuilder() {
25+
return new RecipeBuilder();
26+
}
27+
28+
@Override
29+
public void onReload() {
30+
removeScripted().forEach(org.cyclops.evilcraft.block.BloodInfuser.getInstance().getRecipeRegistry().allRecipes()::remove);
31+
restoreFromBackup().forEach(org.cyclops.evilcraft.block.BloodInfuser.getInstance().getRecipeRegistry().allRecipes()::add);
32+
}
33+
34+
public void add(IRecipe<IngredientFluidStackAndTierRecipeComponent, IngredientRecipeComponent, DurationXpRecipeProperties> recipe) {
35+
this.add(recipe, true);
36+
}
37+
38+
public void add(IRecipe<IngredientFluidStackAndTierRecipeComponent, IngredientRecipeComponent, DurationXpRecipeProperties> recipe, boolean add) {
39+
if (recipe == null) return;
40+
addScripted(recipe);
41+
if (add) org.cyclops.evilcraft.block.BloodInfuser.getInstance().getRecipeRegistry().allRecipes().add(recipe);
42+
}
43+
44+
public boolean remove(IRecipe<IngredientFluidStackAndTierRecipeComponent, IngredientRecipeComponent, DurationXpRecipeProperties> recipe) {
45+
if (recipe == null) return false;
46+
addBackup(recipe);
47+
org.cyclops.evilcraft.block.BloodInfuser.getInstance().getRecipeRegistry().allRecipes().remove(recipe);
48+
return true;
49+
}
50+
51+
public boolean removeByInput(ItemStack input) {
52+
return org.cyclops.evilcraft.block.BloodInfuser.getInstance().getRecipeRegistry().allRecipes().removeIf(r -> {
53+
if (r.getInput().getIngredient().test(input)) {
54+
addBackup(r);
55+
return true;
56+
}
57+
return false;
58+
});
59+
}
60+
61+
public boolean removeByOutput(ItemStack input) {
62+
return org.cyclops.evilcraft.block.BloodInfuser.getInstance().getRecipeRegistry().allRecipes().removeIf(r -> {
63+
if (r.getOutput().getIngredient().test(input)) {
64+
addBackup(r);
65+
return true;
66+
}
67+
return false;
68+
});
69+
}
70+
71+
public void removeAll() {
72+
org.cyclops.evilcraft.block.BloodInfuser.getInstance().getRecipeRegistry().allRecipes().forEach(this::addBackup);
73+
org.cyclops.evilcraft.block.BloodInfuser.getInstance().getRecipeRegistry().allRecipes().clear();
74+
}
75+
76+
public SimpleObjectStream<IRecipe<IngredientFluidStackAndTierRecipeComponent, IngredientRecipeComponent, DurationXpRecipeProperties>> streamRecipes() {
77+
return new SimpleObjectStream<>(org.cyclops.evilcraft.block.BloodInfuser.getInstance().getRecipeRegistry().allRecipes())
78+
.setRemover(this::remove);
79+
}
80+
81+
public static class RecipeBuilder extends AbstractRecipeBuilder<IRecipe<IngredientFluidStackAndTierRecipeComponent, IngredientRecipeComponent, DurationXpRecipeProperties>> {
82+
83+
private static final Fluid bloodFluid = FluidRegistry.getFluid("evilcraftblood");
84+
85+
private int tier = 0;
86+
private int duration = 0;
87+
private float xp = 0;
88+
89+
public RecipeBuilder tier(int tier) {
90+
this.tier = tier;
91+
return this;
92+
}
93+
94+
public RecipeBuilder duration(int duration) {
95+
this.duration = duration;
96+
return this;
97+
}
98+
99+
public RecipeBuilder xp(float xp) {
100+
this.xp = xp;
101+
return this;
102+
}
103+
104+
public RecipeBuilder blood(int amount) {
105+
this.fluidInput.add(new FluidStack(bloodFluid, amount));
106+
return this;
107+
}
108+
109+
public RecipeBuilder fluidInput(int amount) {
110+
this.fluidInput.add(new FluidStack(bloodFluid, amount));
111+
return this;
112+
}
113+
114+
@Override
115+
public String getErrorMsg() {
116+
return "Error adding EvilCraft Blood Infuser Recipe";
117+
}
118+
119+
@Override
120+
public void validate(GroovyLog.Msg msg) {
121+
validateItems(msg, 1, 1, 1, 1);
122+
validateFluids(msg, 1, 1, 0, 0);
123+
msg.add(tier < 0 || tier > 3, "tier must be between 0 and 3, yet it was {}", tier);
124+
msg.add(duration < 0, "duration must be a non negative integer, yet it was {}", duration);
125+
msg.add(xp < 0, "xp must be a non negative integer, yet it was {}", xp);
126+
}
127+
128+
@Override
129+
public @Nullable IRecipe<IngredientFluidStackAndTierRecipeComponent, IngredientRecipeComponent, DurationXpRecipeProperties> register() {
130+
if (!validate()) return null;
131+
IRecipe<IngredientFluidStackAndTierRecipeComponent, IngredientRecipeComponent, DurationXpRecipeProperties> recipe =
132+
org.cyclops.evilcraft.block.BloodInfuser.getInstance().getRecipeRegistry().registerRecipe(
133+
new IngredientFluidStackAndTierRecipeComponent(input.get(0).toMcIngredient(), fluidInput.get(0), tier),
134+
new IngredientRecipeComponent(output.get(0)),
135+
new DurationXpRecipeProperties(duration, xp)
136+
);
137+
ModSupport.EVILCRAFT.get().bloodInfuser.add(recipe, false);
138+
return recipe;
139+
}
140+
}
141+
}

0 commit comments

Comments
 (0)