generated from CleanroomMC/TemplateDevEnv
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* basic better with mods compat * recomment some examples * add more compat, fix errors * obey code review
- Loading branch information
1 parent
4f106e3
commit 3385225
Showing
23 changed files
with
1,974 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/AnvilCrafting.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
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(IIngredient output) { | ||
return AnvilCraftingManager.ANVIL_CRAFTING.removeIf(r -> { | ||
if (output.test(r.getRecipeOutput())) { | ||
addBackup(r); | ||
return true; | ||
} | ||
return false; | ||
}); | ||
} | ||
|
||
@MethodDescription(description = "groovyscript.wiki.removeByInput", example = @Example("item('minecraft:redstone')")) | ||
public boolean removeByInput(IIngredient input) { | ||
return AnvilCraftingManager.ANVIL_CRAFTING.removeIf(r -> { | ||
for (Ingredient ingredient : r.getIngredients()) { | ||
for (ItemStack item : ingredient.getMatchingStacks()) { | ||
if (input.test(item)) { | ||
addBackup(r); | ||
return true; | ||
} | ||
} | ||
} | ||
return false; | ||
}); | ||
} | ||
|
||
@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(); | ||
} | ||
|
||
} |
Oops, something went wrong.