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 Better With Mods compat #131

Merged
merged 4 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
7 changes: 7 additions & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ dependencies {
runtimeOnly rfg.deobf('curse.maven:chisel-235279:2915375')
}

compileOnly rfg.deobf('curse.maven:bwm-suite-246760:3289033')
compileOnly rfg.deobf('curse.maven:bwm-core-294335:2624990')
if (project.debug_better_with_mods.toBoolean()) {
runtimeOnly rfg.deobf('curse.maven:bwm-suite-246760:3289033')
runtimeOnly rfg.deobf('curse.maven:bwm-core-294335:2624990')
}

compileOnly rfg.deobf('curse.maven:mantle-74924:2713386')
if (project.debug_inspirations.toBoolean() || project.debug_tinkers.toBoolean()) {
runtimeOnly rfg.deobf('curse.maven:mantle-74924:2713386')
Expand Down
194 changes: 194 additions & 0 deletions examples/postInit/betterwithmods.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@

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

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

// Anvil Crafting:
// Similar to a normal crafting table, but 4x4 instead.

mods.betterwithmods.anvil_crafting.removeByInput(item('minecraft:redstone'))
mods.betterwithmods.anvil_crafting.removeByOutput(item('betterwithmods:steel_block'))
// mods.betterwithmods.anvil_crafting.removeAll()

mods.betterwithmods.anvil_crafting.shapedBuilder()
.output(item('minecraft:diamond') * 32)
.matrix([[item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),null],
[item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),null],
[item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),null],
[null,null,null,item('minecraft:gold_ingot').transform({ _ -> item('minecraft:diamond') })]])
.register()

mods.betterwithmods.anvil_crafting.shapedBuilder()
.output(item('minecraft:diamond'))
.matrix('BXXX')
.mirrored()
.key('B', item('minecraft:stone'))
.key('X', item('minecraft:gold_ingot'))
.register()

mods.betterwithmods.anvil_crafting.shapelessBuilder()
.name(resource('example:anvil_clay'))
.output(item('minecraft:clay'))
.input([item('minecraft:cobblestone'), item('minecraft:gold_ingot')])
.register()


// Cauldron:
// Converts a large number of items into other items, with the ability to require specific amounts of heat.

mods.betterwithmods.cauldron.removeByInput(item('minecraft:gunpowder'))
mods.betterwithmods.cauldron.removeByOutput(item('minecraft:gunpowder'))
// mods.betterwithmods.cauldron.removeAll()

mods.betterwithmods.cauldron.recipeBuilder()
.input(item('minecraft:clay'))
.output(item('minecraft:diamond'))
.heat(2)
.register()

mods.betterwithmods.cauldron.recipeBuilder()
.input(item('minecraft:diamond'))
.output(item('minecraft:gold_ingot') * 16)
.ignoreHeat()
.register()


// Crucible:
// Converts a large number of items into other items, with the ability to require specific amounts of heat.

mods.betterwithmods.crucible.removeByInput(item('minecraft:gunpowder'))
mods.betterwithmods.crucible.removeByOutput(item('minecraft:gunpowder'))
// mods.betterwithmods.crucible.removeAll()

mods.betterwithmods.crucible.recipeBuilder()
.input(item('minecraft:clay'))
.output(item('minecraft:diamond'))
.heat(2)
.register()

mods.betterwithmods.crucible.recipeBuilder()
.input(item('minecraft:diamond'))
.output(item('minecraft:gold_ingot') * 16)
.ignoreHeat()
.register()


// Heat:
// Creates new levels or adds new blocks to old heat levels.

mods.betterwithmods.heat.add(4, item('minecraft:redstone_block'), item('minecraft:redstone_torch'))
mods.betterwithmods.heat.add(3, 'torch')

// Filtered Hopper:
// Recipes for the Filtered Hopper to process. The filter targeted must allow the input item in to function.

mods.betterwithmods.hopper.removeByInput(item('minecraft:gunpowder'))
mods.betterwithmods.hopper.removeByOutput(item('minecraft:gunpowder'))
// mods.betterwithmods.hopper.removeAll()

mods.betterwithmods.hopper.recipeBuilder()
.name('betterwithmods:iron_bar')
.input(ore('sand'))
.output(item('minecraft:clay'))
.inWorldItemOutput(item('minecraft:gold_ingot'))
.register()

mods.betterwithmods.hopper.recipeBuilder()
.name('betterwithmods:wicker')
.input(item('minecraft:clay'))
.inWorldItemOutput(item('minecraft:gold_ingot'))
.register()


// Hopper Filters:
// Items placed in the middle slot of the Filtered Hopper to restrict what is capable of passing through.

mods.betterwithmods.hopper_filters.removeByFilter(item('minecraft:trapdoor'))
mods.betterwithmods.hopper_filters.removeByName('betterwithmods:ladder')
// mods.betterwithmods.hopper_filters.removeAll()

mods.betterwithmods.hopper_filters.recipeBuilder()
.name('too_weak_to_stop')
.filter(item('minecraft:string'))
.register()

mods.betterwithmods.hopper_filters.recipeBuilder()
.name('groovyscript:clay_only')
.filter(item('minecraft:clay'))
.input(item('minecraft:clay'))
.register()


// Kiln:
// Converts a block into up to three output itemstacks, with the ability to require specific amounts of heat.

mods.betterwithmods.kiln.removeByInput(item('minecraft:end_stone'))
mods.betterwithmods.kiln.removeByOutput(item('minecraft:brick'))
// mods.betterwithmods.kiln.removeAll()

mods.betterwithmods.kiln.recipeBuilder()
.input(item('minecraft:clay'))
.output(item('minecraft:diamond'))
.heat(2)
.register()

mods.betterwithmods.kiln.recipeBuilder()
.input(item('minecraft:diamond_block'))
.output(item('minecraft:gold_ingot') * 16)
.ignoreHeat()
.register()


// Mill Stone:
// Converts input itemstacks into output itemstacks after being ground via rotation power for a given time.

mods.betterwithmods.mill_stone.removeByInput(item('minecraft:netherrack'))
mods.betterwithmods.mill_stone.removeByOutput(item('minecraft:blaze_powder'))
// mods.betterwithmods.mill_stone.removeAll()

mods.betterwithmods.mill_stone.recipeBuilder()
.input(item('minecraft:diamond'))
.output(item('minecraft:gold_ingot') * 16)
.register()

mods.betterwithmods.mill_stone.recipeBuilder()
.input(item('minecraft:diamond_block'))
.output(item('minecraft:gold_ingot'), item('minecraft:gold_block'), item('minecraft:clay'))
.register()


// Saw:
// Converts a block into output itemstacks after being powered via rotation power.

mods.betterwithmods.saw.removeByInput(item('minecraft:vine'))
mods.betterwithmods.saw.removeByOutput(item('minecraft:pumpkin'))
// mods.betterwithmods.saw.removeAll()

mods.betterwithmods.saw.recipeBuilder()
.input(item('minecraft:diamond_block'))
.output(item('minecraft:gold_ingot') * 16)
.register()


// Turntable:
// Converts a block into an output block and up to two itemstacks after being powered via rotation power.

mods.betterwithmods.turntable.removeByInput(item('betterwithmods:unfired_pottery'))
mods.betterwithmods.turntable.removeByOutput(item('minecraft:clay_ball'))
// mods.betterwithmods.turntable.removeAll()

mods.betterwithmods.turntable.recipeBuilder()
.input(item('minecraft:gold_block'))
.outputBlock(blockstate('minecraft:clay'))
.output(item('minecraft:gold_ingot') * 5)
.rotations(5)
.register()

mods.betterwithmods.turntable.recipeBuilder()
.input(item('minecraft:clay'))
.output(item('minecraft:gold_ingot'))
.rotations(2)
.register()


1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ debug_adv_mortars = false
debug_applied_energistics_2 = false
debug_astral = false
debug_avaritia = false
debug_better_with_mods = false
debug_blood_magic = false
debug_botania = false
debug_chisel = 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.appliedenergistics2.AppliedEnergistics2;
import com.cleanroommc.groovyscript.compat.mods.astralsorcery.AstralSorcery;
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.chisel.Chisel;
Expand Down Expand Up @@ -55,6 +56,7 @@ public class ModSupport implements IDynamicGroovyProperty {
public static final GroovyContainer<AppliedEnergistics2> APPLIED_ENERGISTICS_2 = new InternalModContainer<>("appliedenergistics2", "Applied Energistics 2", AppliedEnergistics2::new, "ae2");
public static final GroovyContainer<AstralSorcery> ASTRAL_SORCERY = new InternalModContainer<>("astralsorcery", "Astral Sorcery", AstralSorcery::new, "astral");
public static final GroovyContainer<Avaritia> AVARITIA = new InternalModContainer<>("avaritia", "Avaritia", Avaritia::new);
public static final GroovyContainer<BetterWithMods> BETTER_WITH_MODS = new InternalModContainer<>("betterwithmods", "Better With Mods", BetterWithMods::new);
public static final GroovyContainer<BloodMagic> BLOOD_MAGIC = new InternalModContainer<>("bloodmagic", "Blood Magic: Alchemical Wizardry", BloodMagic::new, "bm");
public static final GroovyContainer<Botania> BOTANIA = new InternalModContainer<>("botania", "Botania", Botania::new);
public static final GroovyContainer<Chisel> CHISEL = new InternalModContainer<>("chisel", "Chisel", Chisel::new);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package com.cleanroommc.groovyscript.compat.mods.betterwithmods;

import betterwithmods.common.registry.anvil.AnvilCraftingManager;
import com.cleanroommc.groovyscript.api.IIngredient;
import com.cleanroommc.groovyscript.api.documentation.annotations.Example;
import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription;
import com.cleanroommc.groovyscript.api.documentation.annotations.RecipeBuilderDescription;
import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription;
import com.cleanroommc.groovyscript.helper.Alias;
import com.cleanroommc.groovyscript.helper.SimpleObjectStream;
import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper;
import com.cleanroommc.groovyscript.registry.VirtualizedRegistry;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.Ingredient;

@RegistryDescription
public class AnvilCrafting extends VirtualizedRegistry<IRecipe> {

public AnvilCrafting() {
super(Alias.generateOfClass(AnvilCrafting.class).andGenerate("SoulforgedSteelAnvil"));
}

@RecipeBuilderDescription(example = {
@Example(".output(item('minecraft:diamond') * 32).matrix([[item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),null],[item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),null],[item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),item('minecraft:gold_ingot'),null],[null,null,null,item('minecraft:gold_ingot').transform({ _ -> item('minecraft:diamond') })]])"),
@Example(".output(item('minecraft:diamond')).matrix('BXXX').mirrored().key('B', item('minecraft:stone')).key('X', item('minecraft:gold_ingot'))")
})
public AnvilRecipeBuilder.Shaped shapedBuilder() {
return new AnvilRecipeBuilder.Shaped();
}

@RecipeBuilderDescription(example = @Example(".name(resource('example:anvil_clay')).output(item('minecraft:clay')).input([item('minecraft:cobblestone'), item('minecraft:gold_ingot')])"))
public AnvilRecipeBuilder.Shapeless shapelessBuilder() {
return new AnvilRecipeBuilder.Shapeless();
}

@Override
public void onReload() {
removeScripted().forEach(recipe -> AnvilCraftingManager.ANVIL_CRAFTING.removeIf(r -> r == recipe));
AnvilCraftingManager.ANVIL_CRAFTING.addAll(restoreFromBackup());
}

public IRecipe add(IRecipe recipe) {
if (recipe != null) {
addScripted(recipe);
AnvilCraftingManager.ANVIL_CRAFTING.add(recipe);
}
return recipe;
}

public boolean remove(IRecipe recipe) {
if (AnvilCraftingManager.ANVIL_CRAFTING.removeIf(r -> r == recipe)) {
addBackup(recipe);
return true;
}
return false;
}

@MethodDescription(description = "groovyscript.wiki.removeByOutput", example = @Example("item('betterwithmods:steel_block')"))
public boolean removeByOutput(ItemStack output) {
WaitingIdly marked this conversation as resolved.
Show resolved Hide resolved
return AnvilCraftingManager.ANVIL_CRAFTING.removeIf(r -> {
if (r.getRecipeOutput().equals(output)) {
addBackup(r);
return true;
}
return false;
});
}

@MethodDescription(description = "groovyscript.wiki.removeByInput", example = @Example("item('minecraft:redstone')"))
public boolean removeByInput(ItemStack input) {
return AnvilCraftingManager.ANVIL_CRAFTING.removeIf(r -> {
for (Ingredient ingredient : r.getIngredients()) {
if (ingredient.test(input)) {
addBackup(r);
return true;
}
}
return false;
});
}

@MethodDescription(description = "groovyscript.wiki.removeByInput")
public boolean removeByInput(IIngredient input) {
return removeByInput(IngredientHelper.toItemStack(input));
}
WaitingIdly marked this conversation as resolved.
Show resolved Hide resolved

@MethodDescription(description = "groovyscript.wiki.streamRecipes", type = MethodDescription.Type.QUERY)
public SimpleObjectStream<IRecipe> streamRecipes() {
return new SimpleObjectStream<>(AnvilCraftingManager.ANVIL_CRAFTING).setRemover(this::remove);
}

@MethodDescription(description = "groovyscript.wiki.removeAll", priority = 2000, example = @Example(commented = true))
public void removeAll() {
AnvilCraftingManager.ANVIL_CRAFTING.forEach(this::addBackup);
AnvilCraftingManager.ANVIL_CRAFTING.clear();
}

}
Loading