Skip to content

Commit

Permalink
add Future MC compat (#254)
Browse files Browse the repository at this point in the history
* future mc

* fix imports
  • Loading branch information
WaitingIdly authored Oct 6, 2024
1 parent ecdcb50 commit 599a59e
Show file tree
Hide file tree
Showing 11 changed files with 490 additions and 4 deletions.
3 changes: 2 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_industrial_foregoing],
'shadowfacts-forgelin-248453:2785465' : [project.debug_alchemistry, project.debug_future_mc, project.debug_industrial_foregoing],
'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 @@ -70,6 +70,7 @@ final def mod_dependencies = [
'extrabotany-299086:3112313' : [project.debug_extra_botany],
'extra-utilities-2-225561:2678374' : [project.debug_extra_utilities_2],
'forestry-59751:2918418' : [project.debug_forestry],
'future-mc-310059:5626387' : [project.debug_future_mc],
'immersive_engineering-231951:2974106' : [project.debug_immersive_engineering, project.debug_immersive_petroleum, project.debug_immersive_technology],
'immersive-petroleum-268250:3382321' : [project.debug_immersive_petroleum],
'mct-immersive-technology-359407:5108047' : [project.debug_immersive_technology],
Expand Down
99 changes: 99 additions & 0 deletions examples/postInit/futuremc.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@

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

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

// Blast Furnace:
// Converts an input itemstack into an output itemstack at the cost of burnable fuel.

mods.futuremc.blast_furnace.removeByInput(item('minecraft:gold_ore'))
mods.futuremc.blast_furnace.removeByOutput(item('minecraft:iron_ingot'))
// mods.futuremc.blast_furnace.removeAll()

mods.futuremc.blast_furnace.recipeBuilder()
.input(item('minecraft:clay'))
.output(item('minecraft:diamond'))
.register()

mods.futuremc.blast_furnace.recipeBuilder()
.input(item('minecraft:gold_ingot'))
.output(item('minecraft:clay'))
.register()


// Campfire:
// Converts an input itemstack into an output itemstack when placed on the Campfire.

mods.futuremc.campfire.removeByInput(item('minecraft:fish'))
mods.futuremc.campfire.removeByOutput(item('minecraft:cooked_mutton'))
// mods.futuremc.campfire.removeAll()

mods.futuremc.campfire.recipeBuilder()
.input(item('minecraft:clay'))
.output(item('minecraft:diamond'))
.duration(10)
.register()

mods.futuremc.campfire.recipeBuilder()
.input(item('minecraft:gold_ingot'))
.output(item('minecraft:clay'))
.duration(1)
.register()


// Smithing:
// Converts two input itemstacks into an output output itemstack in the Smithing Table.

mods.futuremc.smithing.removeByInput(item('minecraft:diamond_hoe'))
// mods.futuremc.smithing.removeByInput(item('futuremc:netherite_ingot'))
mods.futuremc.smithing.removeByOutput(item('futuremc:netherite_pickaxe'))
// mods.futuremc.smithing.removeAll()

mods.futuremc.smithing.recipeBuilder()
.input(item('minecraft:clay'), item('minecraft:gold_ingot'))
.output(item('minecraft:diamond'))
.register()

mods.futuremc.smithing.recipeBuilder()
.input(item('minecraft:gold_ingot') * 4, item('minecraft:clay'))
.output(item('minecraft:clay') * 8)
.register()


// Smoker:
// Converts an input itemstack into an output itemstack at the cost of burnable fuel.

mods.futuremc.smoker.removeByInput(item('minecraft:porkchop'))
mods.futuremc.smoker.removeByOutput(item('minecraft:baked_potato'))
// mods.futuremc.smoker.removeAll()

mods.futuremc.smoker.recipeBuilder()
.input(item('minecraft:clay'))
.output(item('minecraft:diamond'))
.register()

mods.futuremc.smoker.recipeBuilder()
.input(item('minecraft:gold_ingot'))
.output(item('minecraft:clay'))
.register()


// Stoenecutter:
// Converts an input itemstack into an output itemstack via selecting the desired output from the Stonecutter GUI.

mods.futuremc.stonecutter.removeByInput(item('minecraft:stonebrick'))
mods.futuremc.stonecutter.removeByOutput(item('minecraft:stone_slab'))
// mods.futuremc.stonecutter.removeAll()

mods.futuremc.stonecutter.recipeBuilder()
.input(item('minecraft:clay'))
.output(item('minecraft:diamond'))
.register()

mods.futuremc.stonecutter.recipeBuilder()
.input(item('minecraft:gold_ingot'))
.output(item('minecraft:clay'))
.register()


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

debug_forestry = false
debug_future_mc = false

debug_immersive_engineering = false
debug_immersive_petroleum = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
import com.cleanroommc.groovyscript.compat.mods.arcanearchives.ArcaneArchives;
import com.cleanroommc.groovyscript.compat.mods.astralsorcery.AstralSorcery;
import com.cleanroommc.groovyscript.compat.mods.atum.Atum;
import com.cleanroommc.groovyscript.compat.mods.botaniatweaks.BotaniaTweaks;
import com.cleanroommc.groovyscript.compat.mods.avaritia.Avaritia;
import com.cleanroommc.groovyscript.compat.mods.betterwithmods.BetterWithMods;
import com.cleanroommc.groovyscript.compat.mods.bloodmagic.BloodMagic;
import com.cleanroommc.groovyscript.compat.mods.botania.Botania;
import com.cleanroommc.groovyscript.compat.mods.botaniatweaks.BotaniaTweaks;
import com.cleanroommc.groovyscript.compat.mods.botanicadditions.BotanicAdditions;
import com.cleanroommc.groovyscript.compat.mods.calculator.Calculator;
import com.cleanroommc.groovyscript.compat.mods.chisel.Chisel;
Expand All @@ -30,6 +30,7 @@
import com.cleanroommc.groovyscript.compat.mods.extrabotany.ExtraBotany;
import com.cleanroommc.groovyscript.compat.mods.extrautils2.ExtraUtils2;
import com.cleanroommc.groovyscript.compat.mods.forestry.Forestry;
import com.cleanroommc.groovyscript.compat.mods.futuremc.FutureMC;
import com.cleanroommc.groovyscript.compat.mods.ic2.IC2;
import com.cleanroommc.groovyscript.compat.mods.immersiveengineering.ImmersiveEngineering;
import com.cleanroommc.groovyscript.compat.mods.immersivepetroleum.ImmersivePetroleum;
Expand Down Expand Up @@ -63,8 +64,6 @@
import net.minecraftforge.fml.common.discovery.ASMDataTable;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.UnmodifiableView;

import java.util.*;

Expand Down Expand Up @@ -105,6 +104,7 @@ public class ModSupport {
public static final GroovyContainer<ExtraBotany> EXTRA_BOTANY = new InternalModContainer<>("extrabotany", "Extra Botany", ExtraBotany::new);
public static final GroovyContainer<ExtraUtils2> EXTRA_UTILITIES_2 = new InternalModContainer<>("extrautils2", "Extra Utilities 2", ExtraUtils2::new, "extrautilities2");
public static final GroovyContainer<Forestry> FORESTRY = new InternalModContainer<>("forestry", "Forestry", Forestry::new);
public static final GroovyContainer<FutureMC> FUTURE_MC = new InternalModContainer<>("futuremc", "Future MC", FutureMC::new);
public static final GroovyContainer<ImmersiveEngineering> IMMERSIVE_ENGINEERING = new InternalModContainer<>("immersiveengineering", "Immersive Engineering", ImmersiveEngineering::new, "ie");
public static final GroovyContainer<ImmersivePetroleum> IMMERSIVE_PETROLEUM = new InternalModContainer<>("immersivepetroleum", "Immersive Petroleum", ImmersivePetroleum::new);
public static final GroovyContainer<ImmersiveTechnology> IMMERSIVE_TECHNOLOGY = new InternalModContainer<>("immersivetech", "Immersive Technology", ImmersiveTechnology::new);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package com.cleanroommc.groovyscript.compat.mods.futuremc;

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.recipe.AbstractRecipeBuilder;
import com.cleanroommc.groovyscript.registry.StandardListRegistry;
import org.jetbrains.annotations.Nullable;
import thedarkcolour.futuremc.recipe.SimpleRecipe;
import thedarkcolour.futuremc.recipe.furnace.BlastFurnaceRecipes;

import java.util.Arrays;
import java.util.Collection;

@RegistryDescription
public class BlastFurnace extends StandardListRegistry<SimpleRecipe> {

@Override
public Collection<SimpleRecipe> getRecipes() {
return BlastFurnaceRecipes.INSTANCE.getRecipes();
}

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

@MethodDescription(example = @Example("item('minecraft:gold_ore')"))
public void removeByInput(IIngredient input) {
getRecipes().removeIf(r -> Arrays.stream(r.getInput().getMatchingStacks()).anyMatch(input) && addBackup(r));
}

@MethodDescription(example = @Example("item('minecraft:iron_ingot')"))
public void removeByOutput(IIngredient output) {
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<SimpleRecipe> {

@Override
public String getErrorMsg() {
return "Error adding FutureMC Blast Furnace recipe";
}

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

@Override
@RecipeBuilderRegistrationMethod
public @Nullable SimpleRecipe register() {
if (!validate()) return null;
SimpleRecipe recipe = new SimpleRecipe(input.get(0).toMcIngredient(), output.get(0));
ModSupport.FUTURE_MC.get().blastFurnace.add(recipe);
return recipe;
}

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package com.cleanroommc.groovyscript.compat.mods.futuremc;

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.recipe.AbstractRecipeBuilder;
import com.cleanroommc.groovyscript.registry.StandardListRegistry;
import org.jetbrains.annotations.Nullable;
import thedarkcolour.futuremc.recipe.campfire.CampfireRecipe;
import thedarkcolour.futuremc.recipe.campfire.CampfireRecipes;

import java.util.Arrays;
import java.util.Collection;

@RegistryDescription
public class Campfire extends StandardListRegistry<CampfireRecipe> {

@Override
public Collection<CampfireRecipe> getRecipes() {
return CampfireRecipes.INSTANCE.getRecipes();
}

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

@MethodDescription(example = @Example("item('minecraft:fish')"))
public void removeByInput(IIngredient input) {
getRecipes().removeIf(r -> Arrays.stream(r.getInput().getMatchingStacks()).anyMatch(input) && addBackup(r));
}

@MethodDescription(example = @Example("item('minecraft:cooked_mutton')"))
public void removeByOutput(IIngredient output) {
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<CampfireRecipe> {

@Property(comp = @Comp(gte = 1))
private int duration;

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

@Override
public String getErrorMsg() {
return "Error adding FutureMC Campfire recipe";
}

@Override
public void validate(GroovyLog.Msg msg) {
validateItems(msg, 1, 1, 1, 1);
validateFluids(msg);
msg.add(duration <= 0, "duration must be greater than or equal to 1, yet it was {}", duration);
}

@Override
@RecipeBuilderRegistrationMethod
public @Nullable CampfireRecipe register() {
if (!validate()) return null;
CampfireRecipe recipe = new CampfireRecipe(input.get(0).toMcIngredient(), output.get(0), duration);
ModSupport.FUTURE_MC.get().campfire.add(recipe);
return recipe;
}

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.cleanroommc.groovyscript.compat.mods.futuremc;

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

public class FutureMC extends GroovyPropertyContainer {

public final BlastFurnace blastFurnace = new BlastFurnace();
public final Campfire campfire = new Campfire();
public final Smithing smithing = new Smithing();
public final Smoker smoker = new Smoker();
public final Stonecutter stonecutter = new Stonecutter();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package com.cleanroommc.groovyscript.compat.mods.futuremc;

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.recipe.AbstractRecipeBuilder;
import com.cleanroommc.groovyscript.registry.StandardListRegistry;
import org.jetbrains.annotations.Nullable;
import thedarkcolour.futuremc.recipe.smithing.SmithingRecipe;
import thedarkcolour.futuremc.recipe.smithing.SmithingRecipes;

import java.util.Arrays;
import java.util.Collection;

@RegistryDescription(admonition = @Admonition(value = "groovyscript.wiki.futuremc.smithing.note0", type = Admonition.Type.WARNING))
public class Smithing extends StandardListRegistry<SmithingRecipe> {

@Override
public Collection<SmithingRecipe> getRecipes() {
return SmithingRecipes.INSTANCE.getRecipes();
}

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

@MethodDescription(example = {
@Example("item('minecraft:diamond_hoe')"), @Example(value = "item('futuremc:netherite_ingot')", commented = true),
})
public void removeByInput(IIngredient input) {
getRecipes().removeIf(r -> Arrays.stream(r.getInput().getMatchingStacks()).anyMatch(input) && addBackup(r));
}

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

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

@Override
public String getErrorMsg() {
return "Error adding FutureMC Smithing recipe";
}

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

@Override
@RecipeBuilderRegistrationMethod
public @Nullable SmithingRecipe register() {
if (!validate()) return null;
SmithingRecipe recipe = new SmithingRecipe(input.get(0).toMcIngredient(), input.get(1).toMcIngredient(), output.get(0));
ModSupport.FUTURE_MC.get().smithing.add(recipe);
return recipe;
}

}

}
Loading

0 comments on commit 599a59e

Please sign in to comment.