Skip to content

Commit 3de1eb2

Browse files
authored
Tinkers' Construct Documentation (#157)
* 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
1 parent 9f793ff commit 3de1eb2

File tree

13 files changed

+694
-477
lines changed

13 files changed

+694
-477
lines changed
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
2+
// Auto generated groovyscript example file
3+
// MODS_LOADED: tconstruct
4+
5+
println 'mod \'tconstruct\' detected, running script'
6+
7+
// Alloying:
8+
// Modifies what fluids can be mixed together in the Smeltery.
9+
10+
mods.tconstruct.alloying.removeByInputs(fluid('cobalt')*2,fluid('ardite')*2)
11+
mods.tconstruct.alloying.removeByInputsAndOutput(fluid('knightslime')*72,fluid('iron')*72,fluid('stone')*144,fluid('purpleslime')*125)
12+
mods.tconstruct.alloying.removeByOutput(fluid('pigiron'))
13+
// mods.tconstruct.alloying.removeAll()
14+
15+
mods.tconstruct.alloying.recipeBuilder()
16+
.fluidOutput(fluid('iron') * 3)
17+
.fluidInput(fluid('clay') * 1,fluid('lava') * 2)
18+
.register()
19+
20+
21+
mods.tconstruct.alloying.add(fluid('lava') * 144, fluid('water') * 500, fluid('iron') * 5, fluid('clay') * 60)
22+
23+
// Casting Basin:
24+
// Pours out fluid into a basin to solidify it into a solid, optionally with a cast itemstack.
25+
26+
mods.tconstruct.casting_basin.removeByCast(item('minecraft:planks:0'))
27+
mods.tconstruct.casting_basin.removeByInput(fluid('clay'))
28+
mods.tconstruct.casting_basin.removeByOutput(item('minecraft:iron_block'))
29+
// mods.tconstruct.casting_basin.removeAll()
30+
31+
mods.tconstruct.casting_basin.recipeBuilder()
32+
.fluidInput(fluid('water'))
33+
.output(item('minecraft:dirt'))
34+
.cast(item('minecraft:cobblestone'))
35+
.coolingTime(40)
36+
.register()
37+
38+
39+
// Casting Table:
40+
// Pours out fluid onto a table to solidify it into a solid, optionally with a cast itemstack.
41+
42+
mods.tconstruct.casting_table.removeByCast(item('minecraft:bucket'))
43+
mods.tconstruct.casting_table.removeByInput(fluid('iron'))
44+
mods.tconstruct.casting_table.removeByOutput(item('minecraft:gold_ingot'))
45+
// mods.tconstruct.casting_table.removeAll()
46+
47+
mods.tconstruct.casting_table.recipeBuilder()
48+
.fluidInput(fluid('lava') * 50)
49+
.output(item('minecraft:diamond'))
50+
.coolingTime(750)
51+
.consumesCast(true)
52+
.cast(ore('gemEmerald'))
53+
.register()
54+
55+
56+
// Drying Rack:
57+
// Convert an item into a different item by hanging it out to dry.
58+
59+
// mods.tconstruct.drying.removeAll()
60+
61+
mods.tconstruct.drying.recipeBuilder()
62+
.input(item('minecraft:clay'))
63+
.output(item('minecraft:dirt'))
64+
.time(45)
65+
.register()
66+
67+
68+
69+
// Entity Melting:
70+
// Allows mobs to create a bit of fluid when hurt by the Smeltery.
71+
72+
// mods.tconstruct.entity_melting.removeAll()
73+
74+
mods.tconstruct.entity_melting.recipeBuilder()
75+
.fluidOutput(fluid('iron') * 500)
76+
.input(resource('minecraft:pig'))
77+
.register()
78+
79+
80+
// Melting:
81+
// Modifies what items can be melted down in the Smeltery.
82+
83+
// mods.tconstruct.melting.removeAll()
84+
85+
mods.tconstruct.melting.recipeBuilder()
86+
.input(item('minecraft:gravel'))
87+
.fluidOutput(fluid('lava') * 25)
88+
.time(80)
89+
.register()
90+
91+
92+
93+
// Smeltery Fuel:
94+
// Modifies what fluids are accepted as fuels for the Smeltery and how long each fuels the Smeltery.
95+
96+
// mods.tconstruct.smeltery_fuel.removeAll()
97+
98+
mods.tconstruct.smeltery_fuel.addFuel(fluid('water'), 250)
99+

examples/postInit/tinkersconstruct.groovy

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/Alloying.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.cleanroommc.groovyscript.api.GroovyBlacklist;
44
import com.cleanroommc.groovyscript.api.GroovyLog;
5+
import com.cleanroommc.groovyscript.api.documentation.annotations.*;
56
import com.cleanroommc.groovyscript.core.mixin.tconstruct.TinkerRegistryAccessor;
67
import com.cleanroommc.groovyscript.helper.SimpleObjectStream;
78
import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder;
@@ -13,8 +14,10 @@
1314
import java.util.Arrays;
1415
import java.util.List;
1516

17+
@RegistryDescription
1618
public class Alloying extends VirtualizedRegistry<AlloyRecipe> {
1719

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

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

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

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

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

99+
@MethodDescription(priority = 2000, example = @Example(commented = true))
92100
public void removeAll() {
93101
TinkerRegistryAccessor.getAlloyRegistry().forEach(this::addBackup);
94-
TinkerRegistryAccessor.getAlloyRegistry().forEach(TinkerRegistryAccessor.getAlloyRegistry()::remove);
102+
TinkerRegistryAccessor.getAlloyRegistry().clear();
95103
}
96104

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

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

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

113124
@Override
125+
@RecipeBuilderRegistrationMethod
114126
public @Nullable AlloyRecipe register() {
115127
if (!validate()) return null;
116128
AlloyRecipe recipe = new AlloyRecipe(fluidOutput.get(0), fluidInput.toArray(new FluidStack[0]));

0 commit comments

Comments
 (0)