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 Magneticraft compat #255

Merged
merged 8 commits into from
Oct 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 @@ -34,7 +34,7 @@ final def mod_dependencies = [
'aether-255308:3280119' : [project.debug_aether],
'alchemistry-293425:3186612' : [project.debug_alchemistry],
'alchemylib-293426:2761706' : [project.debug_alchemistry],
'shadowfacts-forgelin-248453:2785465' : [project.debug_alchemistry, project.debug_future_mc, project.debug_industrial_foregoing],
'shadowfacts-forgelin-248453:2785465' : [project.debug_alchemistry, project.debug_future_mc, project.debug_industrial_foregoing, project.debug_magneticraft],
'ae2-extended-life-570458:4553942' : [project.debug_applied_energistics_2, project.debug_lazy_ae2],
'arcane-archives-311357:3057332' : [project.debug_arcane_archives],
'guidebook-253874:2989594' : [project.debug_arcane_archives],
Expand Down Expand Up @@ -85,6 +85,8 @@ final def mod_dependencies = [
'integrated-dynamics-236307:3159505' : [project.debug_integrated_dynamics],
'lazy-ae2-322347:3254160' : [project.debug_lazy_ae2],
'libnine-322344:3509087' : [project.debug_lazy_ae2],
'magneticraft-224808:3791484' : [project.debug_magneticraft],
'modelloader-277663:2744735' : [project.debug_magneticraft],
'mekanism-268560:2835175' : [project.debug_mekanism],
'mystical_agriculture-246640:2704562' : [project.debug_mystical_agriculture],
'natures-aura-306626:2882138' : [project.debug_natures_aura],
Expand Down
215 changes: 215 additions & 0 deletions examples/postInit/magneticraft.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@

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

import com.cout970.magneticraft.api.registries.machines.hydraulicpress.HydraulicPressMode

log.info 'mod \'magneticraft\' detected, running script'

// Crushing Table:
// Converts an input itemstack into an output itemstack when placed on top of the Crushing Table and interacted with by a
// Hammer which has.

mods.magneticraft.crushing_table.removeByInput(item('minecraft:iron_ore'))
mods.magneticraft.crushing_table.removeByOutput(item('minecraft:gunpowder'))
// mods.magneticraft.crushing_table.removeAll()

mods.magneticraft.crushing_table.recipeBuilder()
.input(item('minecraft:clay'))
.output(item('minecraft:diamond'))
.register()

mods.magneticraft.crushing_table.recipeBuilder()
.input(item('minecraft:diamond'))
.output(item('minecraft:clay'))
.register()


// Gasification Unit:
// Converts an input itemstack into either an output itemstack, an output fluidstack, or both in a Gasification Unit block.

// mods.magneticraft.gasification_unit.removeAll()

mods.magneticraft.gasification_unit.recipeBuilder()
.input(item('minecraft:clay'))
.output(item('minecraft:diamond'))
.duration(50)
.minTemperature(700)
.register()

mods.magneticraft.gasification_unit.recipeBuilder()
.input(item('minecraft:diamond'))
.fluidOutput(fluid('lava'))
.duration(100)
.minTemperature(500)
.register()


// Grinder:
// Converts an input itemstack into an output itemstack with a chance at a second itemstack in a Grinder Multiblock.

mods.magneticraft.grinder.removeByInput(item('minecraft:iron_ore'))
mods.magneticraft.grinder.removeByOutput(item('minecraft:gravel'))
// mods.magneticraft.grinder.removeAll()

mods.magneticraft.grinder.recipeBuilder()
.input(item('minecraft:clay'))
.output(item('minecraft:diamond'))
.ticks(50)
.register()

mods.magneticraft.grinder.recipeBuilder()
.input(item('minecraft:diamond'))
.output(item('minecraft:clay'), item('minecraft:gold_ingot'))
.chance(10)
.ticks(50)
.register()


// Hydraulic Press:
// Converts an input itemstack into an output itemstack when set to a given mode in a Hydraulic Press Multiblock.

mods.magneticraft.hydraulic_press.removeByInput(item('minecraft:iron_ingot'))
mods.magneticraft.hydraulic_press.removeByMode(HydraulicPressMode.MEDIUM)
mods.magneticraft.hydraulic_press.removeByOutput(item('minecraft:cobblestone'))
// mods.magneticraft.hydraulic_press.removeAll()

mods.magneticraft.hydraulic_press.recipeBuilder()
.input(item('minecraft:clay'))
.output(item('minecraft:diamond'))
.ticks(50)
.register()

mods.magneticraft.hydraulic_press.recipeBuilder()
.input(item('minecraft:gold_ingot'))
.output(item('minecraft:diamond'))
.ticks(50)
.medium()
.register()

mods.magneticraft.hydraulic_press.recipeBuilder()
.input(item('minecraft:diamond'))
.output(item('minecraft:clay'))
.ticks(100)
.mode(HydraulicPressMode.HEAVY)
.register()


// Oil Heater:
// Converts an input fluidstack into an output fluidstack in a Oil Heater Multiblock.

mods.magneticraft.oil_heater.removeByInput(fluid('oil'))
mods.magneticraft.oil_heater.removeByOutput(fluid('steam'))
// mods.magneticraft.oil_heater.removeAll()

mods.magneticraft.oil_heater.recipeBuilder()
.fluidInput(fluid('water'))
.fluidOutput(fluid('lava'))
.duration(50)
.minTemperature(200)
.register()

mods.magneticraft.oil_heater.recipeBuilder()
.fluidInput(fluid('lava'))
.fluidOutput(fluid('water'))
.duration(100)
.minTemperature(50)
.register()


// Refinery:
// Converts an input fluidstack into up to three output fluidstacks in a Refinery Multiblock.

mods.magneticraft.refinery.removeByInput(fluid('steam'))
mods.magneticraft.refinery.removeByOutput(fluid('fuel'))
// mods.magneticraft.refinery.removeAll()

mods.magneticraft.refinery.recipeBuilder()
.fluidInput(fluid('water'))
.fluidOutput(fluid('lava'))
.duration(50)
.register()

mods.magneticraft.refinery.recipeBuilder()
.fluidInput(fluid('lava'))
.fluidOutput(fluid('water'))
.duration(100)
.register()


// Sieve:
// Converts an input itemstack into up to three output itemstacks, each with a separate chance in a Sieve Multiblock.

mods.magneticraft.sieve.removeByInput(item('minecraft:sand'))
mods.magneticraft.sieve.removeByOutput(item('minecraft:quartz'))
// mods.magneticraft.sieve.removeAll()

mods.magneticraft.sieve.recipeBuilder()
.input(item('minecraft:clay'))
.output(item('minecraft:diamond'), 0.5)
.duration(50)
.register()

mods.magneticraft.sieve.recipeBuilder()
.input(item('minecraft:gold_ingot'))
.output(item('minecraft:diamond'), 0.05)
.output(item('minecraft:clay'))
.duration(50)
.register()

mods.magneticraft.sieve.recipeBuilder()
.input(item('minecraft:diamond'))
.output(item('minecraft:clay'), 0.5)
.output(item('minecraft:clay'), 0.5)
.output(item('minecraft:clay'), 0.5)
.duration(1)
.register()


// Sluice Box:
// Converts an input itemstack into any number of output itemstacks each with a given chance. Consumes a bucket of water
// per batch, and can be crafted 10 at a time in a Sluice Box.

mods.magneticraft.sluice_box.removeByInput(item('minecraft:sand'))
mods.magneticraft.sluice_box.removeByOutput(item('minecraft:cobblestone'))
// mods.magneticraft.sluice_box.removeAll()

mods.magneticraft.sluice_box.recipeBuilder()
.input(item('minecraft:gold_ingot'))
.output(item('minecraft:clay'))
.register()

mods.magneticraft.sluice_box.recipeBuilder()
.input(item('minecraft:clay'))
.output(item('minecraft:diamond'), 0.5)
.register()

mods.magneticraft.sluice_box.recipeBuilder()
.input(item('minecraft:diamond'))
.output(item('minecraft:clay'), 0.5)
.output(item('minecraft:clay'), 0.3)
.output(item('minecraft:clay'), 0.2)
.output(item('minecraft:clay'), 0.1)
.register()


// Thermopile:
// The Thermopile generates energy from temperature differences modified by the thermal resistances of the block. This lets
// you generate energy when placed on either side of a Thermopile.

mods.magneticraft.thermopile.removeByInput(blockstate('minecraft:ice'))
// mods.magneticraft.thermopile.removeAll()

mods.magneticraft.thermopile.recipeBuilder()
.state(blockstate('minecraft:clay'))
.conductivity(10)
.temperature(500)
.register()

mods.magneticraft.thermopile.recipeBuilder()
.state(blockstate('minecraft:diamond_block'))
.conductivity(70)
.temperature(700)
.register()


1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ debug_integrated_dynamics = false

debug_lazy_ae2 = false

debug_magneticraft = false
debug_mekanism = false
debug_mystical_agriculture = false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import com.cleanroommc.groovyscript.compat.mods.integrateddynamics.IntegratedDynamics;
import com.cleanroommc.groovyscript.compat.mods.jei.JustEnoughItems;
import com.cleanroommc.groovyscript.compat.mods.lazyae2.LazyAE2;
import com.cleanroommc.groovyscript.compat.mods.magneticraft.Magneticraft;
import com.cleanroommc.groovyscript.compat.mods.mekanism.Mekanism;
import com.cleanroommc.groovyscript.compat.mods.mysticalagriculture.MysticalAgriculture;
import com.cleanroommc.groovyscript.compat.mods.naturesaura.NaturesAura;
Expand Down Expand Up @@ -113,6 +114,7 @@ public class ModSupport {
public static final GroovyContainer<Inspirations> INSPIRATIONS = new InternalModContainer<>("inspirations", "Inspirations", Inspirations::new);
public static final GroovyContainer<IntegratedDynamics> INTEGRATED_DYNAMICS = new InternalModContainer<>("integrateddynamics", "Integrated Dynamics", IntegratedDynamics::new, "id");
public static final GroovyContainer<JustEnoughItems> JEI = new InternalModContainer<>("jei", "Just Enough Items", JustEnoughItems::new, "hei");
public static final GroovyContainer<Magneticraft> MAGNETICRAFT = new InternalModContainer<>("magneticraft", "Magneticraft", Magneticraft::new);
public static final GroovyContainer<Mekanism> MEKANISM = new InternalModContainer<>("mekanism", "Mekanism", Mekanism::new);
public static final GroovyContainer<MysticalAgriculture> MYSTICAL_AGRICULTURE = new InternalModContainer<>("mysticalagriculture", "Mystical Agriculture", MysticalAgriculture::new);
public static final GroovyContainer<LazyAE2> LAZYAE2 = new InternalModContainer<>("threng", "LazyAE2", LazyAE2::new, "lazyae2");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package com.cleanroommc.groovyscript.compat.mods.magneticraft;

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.core.mixin.magneticraft.CrushingTableRecipeManagerAccessor;
import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient;
import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder;
import com.cleanroommc.groovyscript.registry.StandardListRegistry;
import com.cout970.magneticraft.api.MagneticraftApi;
import com.cout970.magneticraft.api.registries.machines.crushingtable.ICrushingTableRecipe;
import org.jetbrains.annotations.Nullable;

import java.util.Collection;

@RegistryDescription
public class CrushingTable extends StandardListRegistry<ICrushingTableRecipe> {

@RecipeBuilderDescription(example = {
@Example(".input(item('minecraft:clay')).output(item('minecraft:diamond'))"),
@Example(".input(item('minecraft:diamond')).output(item('minecraft:clay'))")
})
public RecipeBuilder recipeBuilder() {
return new RecipeBuilder();
}

/**
* Internally, the API method uses {@link java.util.Collections#unmodifiableList},
* so a mixin is required to access the actual list and avoid {@link UnsupportedOperationException}s.
*
* @see com.cout970.magneticraft.api.internal.registries.machines.crushingtable.CrushingTableRecipeManager#getRecipes() MagneticraftApi.getCrushingTableRecipeManager().getRecipes()
*/
@Override
public Collection<ICrushingTableRecipe> getRecipes() {
return CrushingTableRecipeManagerAccessor.getRecipes();
}

@MethodDescription(example = @Example("item('minecraft:iron_ore')"))
public boolean removeByInput(IIngredient input) {
return getRecipes().removeIf(r -> input.test(r.getInput()) && addBackup(r));
}

@MethodDescription(example = @Example("item('minecraft:gunpowder')"))
public boolean removeByOutput(IIngredient output) {
return getRecipes().removeIf(r -> output.test(r.getOutput()) && addBackup(r));
}

@Property(property = "input", comp = @Comp(eq = 1))
@Property(property = "output", comp = @Comp(eq = 1))
public static class RecipeBuilder extends AbstractRecipeBuilder<ICrushingTableRecipe> {

@Override
public String getErrorMsg() {
return "Error adding Magneticraft Crushing Table recipe";
}

@Override
public void validate(GroovyLog.Msg msg) {
validateItems(msg, 1, 1, 1, 1);
validateFluids(msg);
}

@Override
@RecipeBuilderRegistrationMethod
public @Nullable ICrushingTableRecipe register() {
if (!validate()) return null;
ICrushingTableRecipe recipe = null;
if (input.get(0) instanceof OreDictIngredient ore) {
recipe = MagneticraftApi.getCrushingTableRecipeManager().createRecipe(ore.getMatchingStacks()[0], output.get(0), true);
ModSupport.MAGNETICRAFT.get().crushingTable.add(recipe);
} else {
for (var stack : input.get(0).getMatchingStacks()) {
recipe = MagneticraftApi.getCrushingTableRecipeManager().createRecipe(stack, output.get(0), false);
ModSupport.MAGNETICRAFT.get().crushingTable.add(recipe);
}
}
return recipe;
}

}

}
Loading