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 EssentialCraft 4 compatibility #176

Merged
merged 6 commits into from
Jul 6, 2024
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
4 changes: 3 additions & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ final def mod_dependencies = [
'guidebook-253874:2989594' : [project.debug_arcane_archives],
'mystical_lib-277064:3483816' : [project.debug_arcane_archives, project.debug_roots],
'astralsorcery-sorcery-241721:3044416' : [project.debug_astral],
'baubles-227083:2518667' : [project.debug_astral, project.debug_botania, project.debug_thaum],
'baubles-227083:2518667' : [project.debug_astral, project.debug_botania, project.debug_thaum, project.debug_essentialcraft_4],
'avaritia_1_10-261348:3143349' : [project.debug_avaritia],
'bwm-core-294335:2624990' : [project.debug_better_with_mods],
'bwm-suite-246760:3289033' : [project.debug_better_with_mods],
Expand All @@ -53,6 +53,8 @@ final def mod_dependencies = [
'brandons_core-231382:3408276' : [project.debug_draconic_evolution],
'draconic_evolution-223565:3431261' : [project.debug_draconic_evolution],
'redstone_flux-270789:2920436' : [project.debug_draconic_evolution, project.debug_thermal],
'essentialcraft-4-unofficial-254817:5416404' : [project.debug_essentialcraft_4],
'dummycore-unofficial-266491:2611426' : [project.debug_essentialcraft_4],
'cyclops-core-232758:3159497' : [project.debug_evilcraft, project.debug_integrated_dynamics],
'evilcraft-74610:2811267' : [project.debug_evilcraft],
'cucumber-272335:2645867' : [project.debug_extended_crafting],
Expand Down
91 changes: 91 additions & 0 deletions examples/postInit/essentialcraft.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@

// Auto generated groovyscript example file
// MODS_LOADED: essentialcraft

println 'mod \'essentialcraft\' detected, running script'

// Demon Trade:
// Adds an item that can be sold to Demons to obtain Ackronite. Note that each demon that spawns has a random item that it
// can accept, and will not accept any other item.

mods.essentialcraft.demon_trade.remove(entity('minecraft:enderman'))
mods.essentialcraft.demon_trade.remove(item('minecraft:nether_star'))
// mods.essentialcraft.demon_trade.removeAll()

mods.essentialcraft.demon_trade.add(entity('minecraft:chicken'))
mods.essentialcraft.demon_trade.add(item('minecraft:diamond'))

// Magician Table:
// A 5-slot processing machine using MRU. Can be upgraded with various plates to increase its speed.

mods.essentialcraft.magician_table.removeByOutput(item('essentialcraft:genitem'))
// mods.essentialcraft.magician_table.removeAll()

mods.essentialcraft.magician_table.recipeBuilder()
.input(item('minecraft:diamond'), ore('ingotGold'), ore('ingotGold'), ore('stickWood'), ore('stickWood'))
.output(item('minecraft:iron_ingot'))
.mru(500)
.register()


// Magmatic Smeltery:
// A machine used to quadruple ores using MRU and lava. Also adds the same recipes for Magmatic Furnace, which is used to
// double ores using MRU.

mods.essentialcraft.magmatic_smeltery.removeByInput(ore('oreIron'))
mods.essentialcraft.magmatic_smeltery.removeByInput('oreDiamond')
// mods.essentialcraft.magmatic_smeltery.removeAll()

mods.essentialcraft.magmatic_smeltery.recipeBuilder()
.input('blockIron')
.output('ingotGold')
.factor(3)
.color(0x0000ff)
.register()


// Mithriline Furnace:
// Converts various items into other items using ESPE.

mods.essentialcraft.mithriline_furnace.removeByInput(ore('dustGlowstone'))
mods.essentialcraft.mithriline_furnace.removeByOutput(item('minecraft:emerald'))
// mods.essentialcraft.mithriline_furnace.removeAll()

mods.essentialcraft.mithriline_furnace.recipeBuilder()
.input(item('minecraft:coal_block') * 3)
.output(item('minecraft:diamond_block'))
.espe(500)
.register()


// Radiating Chamber:
// Combines two items together using MRU to obtain a third item. Can optionally require a specific range of MRU balance to
// execute the recipe.

mods.essentialcraft.radiating_chamber.removeByOutput(item('essentialcraft:genitem', 42))
// mods.essentialcraft.radiating_chamber.removeAll()

mods.essentialcraft.radiating_chamber.recipeBuilder()
.input(item('minecraft:nether_star'), item('minecraft:stone'))
.output(item('minecraft:beacon'))
.time(100)
.mruPerTick(10.0f)
.upperBalance(1.5f)
.lowerBalance(0.25f)
.register()


// Wind Rune:
// Transforms various items using ESPE.

mods.essentialcraft.wind_rune.removeByInput(item('minecraft:diamond'))
mods.essentialcraft.wind_rune.removeByOutput(item('essentialcraft:air_potion'))
// mods.essentialcraft.wind_rune.removeAll()

mods.essentialcraft.wind_rune.recipeBuilder()
.input(item('minecraft:gold_block'))
.output(item('minecraft:diamond_block'))
.espe(500)
.register()


1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ debug_chisel = false
debug_compact_machines = false
debug_draconic_evolution = false
debug_enderio = false
debug_essentialcraft_4 = false
debug_evilcraft = false
debug_extended_crafting = false
debug_extra_utilities_2 = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.cleanroommc.groovyscript.compat.mods.compactmachines.CompactMachines;
import com.cleanroommc.groovyscript.compat.mods.draconicevolution.DraconicEvolution;
import com.cleanroommc.groovyscript.compat.mods.enderio.EnderIO;
import com.cleanroommc.groovyscript.compat.mods.essentialcraft.EssentialCraft;
import com.cleanroommc.groovyscript.compat.mods.evilcraft.EvilCraft;
import com.cleanroommc.groovyscript.compat.mods.extendedcrafting.ExtendedCrafting;
import com.cleanroommc.groovyscript.compat.mods.extrautils2.ExtraUtils2;
Expand Down Expand Up @@ -75,6 +76,7 @@ public class ModSupport implements IDynamicGroovyProperty {
public static final GroovyContainer<CompactMachines> COMPACT_MACHINES = new InternalModContainer<>("compactmachines3", "Compact Machines 3", CompactMachines::new, "compactmachines");
public static final GroovyContainer<DraconicEvolution> DRACONIC_EVOLUTION = new InternalModContainer<>("draconicevolution", "Draconic Evolution", DraconicEvolution::new, "de");
public static final GroovyContainer<EnderIO> ENDER_IO = new InternalModContainer<>("enderio", "Ender IO", EnderIO::new, "eio");
public static final GroovyContainer<EssentialCraft> ESSENTIALCRAFT = new InternalModContainer<>("essentialcraft", "EssentialCraft 4", EssentialCraft::new, "ec4");
public static final GroovyContainer<EvilCraft> EVILCRAFT = new InternalModContainer<>("evilcraft", "EvilCraft", EvilCraft::new);
public static final GroovyContainer<ExtendedCrafting> EXTENDED_CRAFTING = new InternalModContainer<>("extendedcrafting", "Extended Crafting", ExtendedCrafting::new);
public static final GroovyContainer<ExtraUtils2> EXTRA_UTILITIES_2 = new InternalModContainer<>("extrautils2", "Extra Utilities 2", ExtraUtils2::new, "extrautilities2");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package com.cleanroommc.groovyscript.compat.mods.essentialcraft;

import com.cleanroommc.groovyscript.api.IIngredient;
import com.cleanroommc.groovyscript.api.documentation.annotations.Admonition;
import com.cleanroommc.groovyscript.api.documentation.annotations.Example;
import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription;
import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription;
import com.cleanroommc.groovyscript.helper.Alias;
import com.cleanroommc.groovyscript.helper.SimpleObjectStream;
import com.cleanroommc.groovyscript.registry.VirtualizedRegistry;
import net.minecraft.item.ItemStack;
import essentialcraft.api.DemonTrade;
import net.minecraftforge.fml.common.registry.EntityEntry;

@RegistryDescription(
category = RegistryDescription.Category.ENTRIES,
admonition = @Admonition(value = "groovyscript.wiki.essentialcraft.demon_trade.note0", type = Admonition.Type.DANGER))
public class DemonTradeManager extends VirtualizedRegistry<DemonTrade> {
public DemonTradeManager() {
super(Alias.generateOf("DemonTrade"));
}

@Override
public void onReload() {
removeScripted().forEach(DemonTrade::removeTrade);
restoreFromBackup().forEach(r -> {
DemonTrade.TRADES.add(r);
if (r.desiredItem.isEmpty()) {
DemonTrade.ALL_MOBS.add(r.entityType);
Wizzerinus marked this conversation as resolved.
Show resolved Hide resolved
}
});
}

@MethodDescription(example = @Example("item('minecraft:diamond')"), type = MethodDescription.Type.ADDITION)
public void add(IIngredient x) {
for (ItemStack it : x.getMatchingStacks()) {
DemonTrade t = new DemonTrade(it); // this automatically registers the trade
addScripted(t);
}
}

@MethodDescription(example = @Example("entity('minecraft:chicken')"), type = MethodDescription.Type.ADDITION)
public void add(EntityEntry x) {
DemonTrade t = new DemonTrade(x); // this automatically registers the trade
addScripted(t);
}

@MethodDescription(example = @Example("item('minecraft:nether_star')"))
public boolean remove(IIngredient x) {
return DemonTrade.TRADES.removeIf(r -> {
if (!r.desiredItem.isEmpty() && x.test(r.desiredItem)) {
addBackup(r);
return true;
}
return false;
});
}

@MethodDescription(description = "groovyscript.wiki.essentialcraft.demon_trade.removeEntity", example = @Example("entity('minecraft:enderman')"))
public boolean remove(EntityEntry x) {
return DemonTrade.TRADES.removeIf(r -> {
if (r.desiredItem.isEmpty() && x.equals(r.entityType)) {
addBackup(r);
DemonTrade.ALL_MOBS.remove(r.entityType);
return true;
}
return false;
});
}

private boolean remove(DemonTrade t) {
if (DemonTrade.TRADES.stream().anyMatch(r -> r.equals(t))) {
addBackup(t);
DemonTrade.removeTrade(t);
return true;
}
return false;
}

@MethodDescription(priority = 2000, example = @Example(commented = true))
public void removeAll() {
DemonTrade.TRADES.forEach(this::addBackup);
DemonTrade.TRADES.clear();
DemonTrade.ALL_MOBS.clear();
}

@MethodDescription(type = MethodDescription.Type.QUERY)
public SimpleObjectStream<DemonTrade> streamRecipes() {
return new SimpleObjectStream<>(DemonTrade.TRADES).setRemover(this::remove);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.cleanroommc.groovyscript.compat.mods.essentialcraft;

import com.cleanroommc.groovyscript.compat.mods.ModPropertyContainer;

public class EssentialCraft extends ModPropertyContainer {
public final DemonTradeManager demonTrade = new DemonTradeManager();
public final MagicianTable magicianTable = new MagicianTable();
public final MagmaticSmeltery magmaticSmeltery = new MagmaticSmeltery();
public final MithrilineFurnace mithrilineFurnace = new MithrilineFurnace();
public final RadiatingChamber radiatingChamber = new RadiatingChamber();
public final WindRune windRune = new WindRune();

public EssentialCraft() {
addRegistry(demonTrade);
addRegistry(magicianTable);
addRegistry(magmaticSmeltery);
addRegistry(mithrilineFurnace);
addRegistry(radiatingChamber);
addRegistry(windRune);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package com.cleanroommc.groovyscript.compat.mods.essentialcraft;

import com.cleanroommc.groovyscript.api.GroovyLog;
import com.cleanroommc.groovyscript.api.IIngredient;
import com.cleanroommc.groovyscript.api.documentation.annotations.*;
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 essentialcraft.api.MagicianTableRecipe;
import essentialcraft.api.MagicianTableRecipes;
import net.minecraft.item.crafting.Ingredient;
import org.jetbrains.annotations.Nullable;

@RegistryDescription(admonition = @Admonition(value = "groovyscript.wiki.essentialcraft.magician_table.note0", type = Admonition.Type.WARNING))
public class MagicianTable extends VirtualizedRegistry<MagicianTableRecipe> {

@RecipeBuilderDescription(example = @Example(".input(item('minecraft:diamond'), ore('ingotGold'), ore('ingotGold'), ore('stickWood'), ore('stickWood')).output(item('minecraft:iron_ingot')).mru(500)"))
public MagicianTable.RecipeBuilder recipeBuilder() {
return new MagicianTable.RecipeBuilder();
}

@Override
public void onReload() {
removeScripted().forEach(MagicianTableRecipes::removeRecipe);
restoreFromBackup().forEach(MagicianTableRecipes::addRecipe);
}

@MethodDescription(example = @Example("item('essentialcraft:genitem')"))
public boolean removeByOutput(IIngredient x) {
return MagicianTableRecipes.RECIPES.removeIf(r -> {
if (x.test(r.getRecipeOutput())) {
addBackup(r);
return true;
}
return false;
});
}

@MethodDescription(priority = 2000, example = @Example(commented = true))
public void removeAll() {
MagicianTableRecipes.RECIPES.forEach(this::addBackup);
MagicianTableRecipes.RECIPES.clear();
}

@MethodDescription(type = MethodDescription.Type.QUERY)
public SimpleObjectStream<MagicianTableRecipe> streamRecipes() {
return new SimpleObjectStream<>(MagicianTableRecipes.RECIPES).setRemover(r -> {
addBackup(r);
return MagicianTableRecipes.RECIPES.remove(r);
});
}

@Property(property = "input", valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "5", type = Comp.Type.LTE)})
@Property(property = "output", valid = @Comp("1"))
public static class RecipeBuilder extends AbstractRecipeBuilder<MagicianTableRecipe> {
@Property(valid = @Comp(type = Comp.Type.GTE, value = "1"))
Wizzerinus marked this conversation as resolved.
Show resolved Hide resolved
private int mru;

@RecipeBuilderMethodDescription
public RecipeBuilder mru(int cost) {
mru = cost;
return this;
}

@Override
public String getErrorMsg() {
return "Error adding Magician Table Recipe";
}

@Override
public void validate(GroovyLog.Msg msg) {
validateItems(msg, 1, 5, 1, 1);
validateFluids(msg);
msg.add(mru < 1, "mru cost must be 1 or greater, got {}", mru);
}

@Override
@RecipeBuilderRegistrationMethod
public @Nullable MagicianTableRecipe register() {
if (!validate()) return null;
Ingredient[] inputIngredient = input.stream().map(IIngredient::toMcIngredient).toArray(Ingredient[]::new);
MagicianTableRecipe recipe = new MagicianTableRecipe(inputIngredient, output.get(0), mru);
ModSupport.ESSENTIALCRAFT.get().magicianTable.addScripted(recipe);
MagicianTableRecipes.addRecipe(recipe);
return recipe;
}
}
}
Loading