Skip to content

Commit

Permalink
Tinkers' Construct Documentation (#157)
Browse files Browse the repository at this point in the history
* Basic docs

* Finish docs

* Add example script

* Add .register()

* Split entity melting

* Changes

* Update en_us.lang

* Gen example script

* Fix errors

* Split casting into different files

* Better descriptions

* forgor the script 💀

* Use resource handler

* add register description

* use clear for entity melting

* Improve alloying description

* alloying removal examples

* Ahhh

* Use description defaults

* use clear()

* `

* the schizophrenia is getting worse

* Add missing lang key

* add property annotations
  • Loading branch information
Testure authored May 23, 2024
1 parent 9f793ff commit 3de1eb2
Show file tree
Hide file tree
Showing 13 changed files with 694 additions and 477 deletions.
99 changes: 99 additions & 0 deletions examples/postInit/tconstruct.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@

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

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

// Alloying:
// Modifies what fluids can be mixed together in the Smeltery.

mods.tconstruct.alloying.removeByInputs(fluid('cobalt')*2,fluid('ardite')*2)
mods.tconstruct.alloying.removeByInputsAndOutput(fluid('knightslime')*72,fluid('iron')*72,fluid('stone')*144,fluid('purpleslime')*125)
mods.tconstruct.alloying.removeByOutput(fluid('pigiron'))
// mods.tconstruct.alloying.removeAll()

mods.tconstruct.alloying.recipeBuilder()
.fluidOutput(fluid('iron') * 3)
.fluidInput(fluid('clay') * 1,fluid('lava') * 2)
.register()


mods.tconstruct.alloying.add(fluid('lava') * 144, fluid('water') * 500, fluid('iron') * 5, fluid('clay') * 60)

// Casting Basin:
// Pours out fluid into a basin to solidify it into a solid, optionally with a cast itemstack.

mods.tconstruct.casting_basin.removeByCast(item('minecraft:planks:0'))
mods.tconstruct.casting_basin.removeByInput(fluid('clay'))
mods.tconstruct.casting_basin.removeByOutput(item('minecraft:iron_block'))
// mods.tconstruct.casting_basin.removeAll()

mods.tconstruct.casting_basin.recipeBuilder()
.fluidInput(fluid('water'))
.output(item('minecraft:dirt'))
.cast(item('minecraft:cobblestone'))
.coolingTime(40)
.register()


// Casting Table:
// Pours out fluid onto a table to solidify it into a solid, optionally with a cast itemstack.

mods.tconstruct.casting_table.removeByCast(item('minecraft:bucket'))
mods.tconstruct.casting_table.removeByInput(fluid('iron'))
mods.tconstruct.casting_table.removeByOutput(item('minecraft:gold_ingot'))
// mods.tconstruct.casting_table.removeAll()

mods.tconstruct.casting_table.recipeBuilder()
.fluidInput(fluid('lava') * 50)
.output(item('minecraft:diamond'))
.coolingTime(750)
.consumesCast(true)
.cast(ore('gemEmerald'))
.register()


// Drying Rack:
// Convert an item into a different item by hanging it out to dry.

// mods.tconstruct.drying.removeAll()

mods.tconstruct.drying.recipeBuilder()
.input(item('minecraft:clay'))
.output(item('minecraft:dirt'))
.time(45)
.register()



// Entity Melting:
// Allows mobs to create a bit of fluid when hurt by the Smeltery.

// mods.tconstruct.entity_melting.removeAll()

mods.tconstruct.entity_melting.recipeBuilder()
.fluidOutput(fluid('iron') * 500)
.input(resource('minecraft:pig'))
.register()


// Melting:
// Modifies what items can be melted down in the Smeltery.

// mods.tconstruct.melting.removeAll()

mods.tconstruct.melting.recipeBuilder()
.input(item('minecraft:gravel'))
.fluidOutput(fluid('lava') * 25)
.time(80)
.register()



// Smeltery Fuel:
// Modifies what fluids are accepted as fuels for the Smeltery and how long each fuels the Smeltery.

// mods.tconstruct.smeltery_fuel.removeAll()

mods.tconstruct.smeltery_fuel.addFuel(fluid('water'), 250)

24 changes: 0 additions & 24 deletions examples/postInit/tinkersconstruct.groovy

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.cleanroommc.groovyscript.api.GroovyBlacklist;
import com.cleanroommc.groovyscript.api.GroovyLog;
import com.cleanroommc.groovyscript.api.documentation.annotations.*;
import com.cleanroommc.groovyscript.core.mixin.tconstruct.TinkerRegistryAccessor;
import com.cleanroommc.groovyscript.helper.SimpleObjectStream;
import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder;
Expand All @@ -13,8 +14,10 @@
import java.util.Arrays;
import java.util.List;

@RegistryDescription
public class Alloying extends VirtualizedRegistry<AlloyRecipe> {

@RecipeBuilderDescription(example = @Example(".fluidOutput(fluid('iron') * 3).fluidInput(fluid('clay') * 1,fluid('lava') * 2)"))
public RecipeBuilder recipeBuilder() {
return new RecipeBuilder();
}
Expand All @@ -26,6 +29,7 @@ public void onReload() {
restoreFromBackup().forEach(TinkerRegistryAccessor.getAlloyRegistry()::add);
}

@MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("fluid('lava') * 144, fluid('water') * 500, fluid('iron') * 5, fluid('clay') * 60"))
public AlloyRecipe add(FluidStack output, FluidStack... inputs) {
AlloyRecipe recipe = new AlloyRecipe(output, inputs);
add(recipe);
Expand All @@ -45,6 +49,7 @@ public boolean remove(AlloyRecipe recipe) {
return true;
}

@MethodDescription(example = @Example("fluid('pigiron')"))
public boolean removeByOutput(FluidStack output) {
if (TinkerRegistryAccessor.getAlloyRegistry().removeIf(recipe -> {
boolean found = recipe.getResult().isFluidEqual(output);
Expand All @@ -59,6 +64,7 @@ public boolean removeByOutput(FluidStack output) {
return false;
}

@MethodDescription(description = "groovyscript.wiki.tconstruct.alloying.removeByInputs", example = @Example("fluid('cobalt')*2,fluid('ardite')*2"))
public boolean removeByInputs(FluidStack... inputs) {
List<FluidStack> list = Arrays.asList(inputs);
if (TinkerRegistryAccessor.getAlloyRegistry().removeIf(recipe -> {
Expand All @@ -74,6 +80,7 @@ public boolean removeByInputs(FluidStack... inputs) {
return false;
}

@MethodDescription(example = @Example("fluid('knightslime')*72,fluid('iron')*72,fluid('stone')*144,fluid('purpleslime')*125"))
public boolean removeByInputsAndOutput(FluidStack output, FluidStack... inputs) {
List<FluidStack> list = Arrays.asList(inputs);
if (TinkerRegistryAccessor.getAlloyRegistry().removeIf(recipe -> {
Expand All @@ -89,15 +96,19 @@ public boolean removeByInputsAndOutput(FluidStack output, FluidStack... inputs)
return false;
}

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

@MethodDescription(type = MethodDescription.Type.QUERY)
public SimpleObjectStream<AlloyRecipe> streamRecipes() {
return new SimpleObjectStream<>(TinkerRegistryAccessor.getAlloyRegistry()).setRemover(this::remove);
}

@Property(property = "fluidInput", valid = {@Comp(value = "2", type = Comp.Type.GTE), @Comp(value = "Integer.MAX_VALUE", type = Comp.Type.LTE)})
@Property(property = "fluidOutput", valid = @Comp("1"))
public class RecipeBuilder extends AbstractRecipeBuilder<AlloyRecipe> {

@Override
Expand All @@ -111,6 +122,7 @@ public void validate(GroovyLog.Msg msg) {
}

@Override
@RecipeBuilderRegistrationMethod
public @Nullable AlloyRecipe register() {
if (!validate()) return null;
AlloyRecipe recipe = new AlloyRecipe(fluidOutput.get(0), fluidInput.toArray(new FluidStack[0]));
Expand Down
Loading

0 comments on commit 3de1eb2

Please sign in to comment.