Skip to content

Commit e9cab59

Browse files
authored
update docs for GroovyScript 1.3.0 (#52)
* update docs * update vanilla * update more unique docs * enhance object mapper documentation
1 parent bbe7c81 commit e9cab59

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+4570
-216
lines changed

docs/groovy-script/getting_started/groovy_log.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ This can help improve readability of the log file, yet may hide errors that stil
2727
## Interacting
2828

2929

30-
There are six main ways to add messages to the log file.
30+
There are seven main ways to add messages to the log file.
3131
Each has a different purpose and level of severity.
3232

33+
The most basic way is calling `log(String)`, which logs the message on the info channel.
34+
3335
When adding messages to the log via these methods,
3436
the time, side, log channel, currently loaded script, and currently running line
3537
will be printed to the log file.
@@ -51,7 +53,7 @@ the [debug](./run_config.md#debug) option in the [`runConfig.json`](./run_config
5153
### Info
5254

5355

54-
Called via `log.info(String)`, this indicates that the information is
56+
Called via either `log(String)` or `log.info(String)`, this indicates that the information is
5557
used to provide a record of the normal operation of the system.
5658

5759

docs/groovy-script/getting_started/object_mappers.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,65 @@ Currently, the best way to observe what Object Mappers will do is to use the Lan
6666
:::
6767

6868
- [All Vanilla Object Mappers](../minecraft/vanilla_object_mappers.md)
69+
70+
71+
## General Methods
72+
73+
74+
Many Object Mappers share the same set of the methods.
75+
Many of these methods utilize [Operator Overloading](../groovy/operators.md#operator-overloading),
76+
which allows things like `item(...)` to be an alias of `item.call(...)`.
77+
78+
79+
### Retrieval
80+
81+
Using `call(...)` returns the relevant data of the Object Mapper,
82+
and is the primary purpose of an Object Mapper's existence.
83+
<br>
84+
Every Object Mapper has this capability, with the parameters varying based on the Object Mapper.
85+
86+
See above for examples of this.
87+
88+
89+
### Default Value
90+
91+
92+
Using `call()` without any parameters will attempt to return
93+
the default value of the Object Mapper, presuming it exists.
94+
If it does not exist, `null` will be returned instead
95+
<br>
96+
Some Object Mappers have this functionality.
97+
98+
::: info Example {id="example"}
99+
100+
```groovy
101+
item() // returns ItemStack.EMPTY
102+
block() // returns Blocks.AIR
103+
creativeTab() // returns CreativeTabs.SEARCH
104+
```
105+
106+
:::
107+
108+
109+
### Inversion
110+
111+
112+
Using `mod(...)` returns a String that can create the retrieval method
113+
of the parameter, presuming that the parameter is of the type that the Object Mapper returns.
114+
<br>
115+
The main purpose of this is to convert an object obtained through some means
116+
into text interpretable by GroovyScript.
117+
For some Object Mappers, there are multiple valid ways to retrieve the same object -
118+
in such a situation, the return value will only be one of those ways.
119+
<br>
120+
Most Object Mappers have this capability.
121+
122+
::: info Example {id="example"}
123+
124+
```groovy
125+
log(item % item('minecraft:clay')) // returns item('minecraft:clay')
126+
log(blockstate % blockstate('minecraft:log:0')) // returns blockstate('minecraft:log', 'axis=y', 'variant=oak')
127+
log(item % minecraft.getAllItems()) // returns a String for every item from vanilla minecraft
128+
```
129+
130+
:::

docs/groovy-script/getting_started/run_config.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,23 +79,31 @@ It currently doesn't do anything special.
7979
If this is false all messages that logged to debug will not be logged.
8080
This setting is great for debugging, as it adds additional information to the [`groovy.log`](./groovy_log.md)
8181
and logs the line numbers in errors.
82+
<br>
83+
This also controls if [keybindings](../minecraft/keybindings.md) are bound by default.
8284
- Can be accessed in a script via `isDebug()`.
8385

8486
## `classes`
8587

8688
This *was* an element used to control what files were loaded as class files
8789
prior to [GroovyScript 1.2.3](https://github.com/CleanroomMC/GroovyScript/tree/v1.2.3).
8890

89-
::: info Failure {id="failure"}
91+
:::: info Warning {id="warning"}
9092

91-
If `classes` is an element in your `runConfig.json` file, a fatal message will be logged
92-
and you **must** remove it in order to be able to launch.
93+
If `classes` is an element in your `runConfig.json` file, a error message will be logged.
9394

9495
Instead, load your classes via one of the loaders - typically [`preInit`](#preinit).
9596
To migrate in this fashion, simply add `"classes/"` to the `preInit` loader.
9697

98+
::: info Failure {id="failure"}
99+
100+
Prior to [GroovyScript 1.3.0](https://github.com/CleanroomMC/GroovyScript/tree/v1.3.0)
101+
this would generate a fatal error, crashing the game.
102+
97103
:::
98104

105+
::::
106+
99107
:::: details Prior to GroovyScript 1.2.3 {id="warning"}
100108

101109
Files that contain a single class should be specified here.

docs/groovy-script/minecraft/helpers/command.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ Create custom commands, either generally or specifically for the client.
1616
Refer to this via any of the following:
1717

1818
```groovy:no-line-numbers {1}
19-
command/* Used as page default */ // [!code focus]
20-
Command
21-
minecraft.command
19+
minecraft.command/* Used as page default */ // [!code focus]
2220
minecraft.Command
2321
Minecraft.command
2422
Minecraft.Command
@@ -40,48 +38,48 @@ mods.minecraft.Command
4038
- Registers the given command to the client:
4139

4240
```groovy:no-line-numbers
43-
command.registerClientCommand(ICommand)
41+
minecraft.command.registerClientCommand(ICommand)
4442
```
4543
4644
- Registers the given command to the client in the format `name`, `command`, with `command` being a Closure taking 3 parameters, `MinecraftServer server`, `ICommandSender sender`, and `String... args`:
4745
4846
```groovy:no-line-numbers
49-
command.registerClientCommand(String, SimpleCommand.ICommand)
47+
minecraft.command.registerClientCommand(String, SimpleCommand.ICommand)
5048
```
5149
5250
- Registers the given command to the client in the format `name`, `usage`, `command`, with `command` being a Closure taking 3 parameters, `MinecraftServer server`, `ICommandSender sender`, and `String... args`:
5351
5452
```groovy:no-line-numbers
55-
command.registerClientCommand(String, String, SimpleCommand.ICommand)
53+
minecraft.command.registerClientCommand(String, String, SimpleCommand.ICommand)
5654
```
5755
5856
- Registers the given command to the given command handler, in the format `handler`, `command`:
5957
6058
```groovy:no-line-numbers
61-
command.registerCommand(CommandHandler, ICommand)
59+
minecraft.command.registerCommand(CommandHandler, ICommand)
6260
```
6361
6462
- Registers the given command:
6563
6664
```groovy:no-line-numbers
67-
command.registerCommand(ICommand)
65+
minecraft.command.registerCommand(ICommand)
6866
```
6967
7068
- Registers the given command in the format `name`, `command`, with `command` being a Closure taking 3 parameters, `MinecraftServer server`, `ICommandSender sender`, and `String... args`:
7169
7270
```groovy:no-line-numbers
73-
command.registerCommand(String, SimpleCommand.ICommand)
71+
minecraft.command.registerCommand(String, SimpleCommand.ICommand)
7472
```
7573
7674
- Registers the given command in the format `name`, `usage`, `command`, with `command` being a Closure taking 3 parameters, `MinecraftServer server`, `ICommandSender sender`, and `String... args`:
7775
7876
```groovy:no-line-numbers
79-
command.registerCommand(String, String, SimpleCommand.ICommand)
77+
minecraft.command.registerCommand(String, String, SimpleCommand.ICommand)
8078
```
8179
8280
:::::::::: details Example {open id="example"}
8381
```groovy:no-line-numbers
84-
command.registerCommand('groovy_test', { server, sender, args -> sender.sendMessage('Hello from GroovyScript')})
82+
minecraft.command.registerCommand('groovy_test', { server, sender, args -> sender.sendMessage('Hello from GroovyScript')})
8583
```
8684

8785
::::::::::

docs/groovy-script/minecraft/helpers/furnace.md

Lines changed: 62 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
---
22
title: "Furnace"
33
titleTemplate: "Minecraft | CleanroomMC"
4-
description: "Converts an input item into an output itemstack after a set amount of time, with the ability to give experience and using fuel to run."
4+
description: "Converts an input item into an output itemstack after a configurable amount of time, with the ability to give experience and using fuel to run. Can also convert the item in the fuel slot."
55
source_code_link: "https://github.com/CleanroomMC/GroovyScript/blob/master/src/main/java/com/cleanroommc/groovyscript/compat/vanilla/Furnace.java"
66
---
77

88
# Furnace (Minecraft)
99

1010
## Description
1111

12-
Converts an input item into an output itemstack after a set amount of time, with the ability to give experience and using fuel to run.
12+
Converts an input item into an output itemstack after a configurable amount of time, with the ability to give experience and using fuel to run. Can also convert the item in the fuel slot.
13+
14+
:::::::::: details Note {open id="note"}
15+
Fuel Conversion Recipes may not function as desired in all furnaces - only the vanilla furnace has specific support. By default the only recipe reproduces the vanilla behavior of a wet sponge converting an empty bucket into a water bucket.
16+
::::::::::
1317

1418
## Identifier
1519

@@ -49,10 +53,30 @@ mods.minecraft.Furnace
4953
furnace.add(IIngredient, ItemStack, float)
5054
```
5155
56+
- Adds a recipe in the format `input`, `output`, `experience`, `time`:
57+
58+
```groovy:no-line-numbers
59+
furnace.add(IIngredient, ItemStack, float, int)
60+
```
61+
62+
- Add the given recipe to the recipe list:
63+
64+
```groovy:no-line-numbers
65+
furnace.addFuelConversion(CustomFurnaceManager.FuelConversionRecipe)
66+
```
67+
68+
- Add a conversion recipe in the format `smelted`, `fuel`, with `fuel` using an IIngredient transformer:
69+
70+
```groovy:no-line-numbers
71+
furnace.addFuelConversion(IIngredient, IIngredient)
72+
```
73+
5274
:::::::::: details Example {open id="example"}
5375
```groovy:no-line-numbers
5476
furnace.add(ore('ingotIron'), item('minecraft:diamond'))
5577
furnace.add(item('minecraft:nether_star'), item('minecraft:clay') * 64, 13)
78+
furnace.add(item('minecraft:diamond'), item('minecraft:clay'), 2, 50)
79+
furnace.addFuelConversion(item('minecraft:diamond'), item('minecraft:bucket').transform(item('minecraft:lava_bucket')))
5680
```
5781

5882
::::::::::
@@ -91,10 +115,17 @@ Don't know what a builder is? Check [the builder info page](../../getting_starte
91115
output(Collection<ItemStack>)
92116
```
93117
94-
- `float`. Sets the experience rewarded for smelting the given input. Requires greater than or equal to 0. (Default `0.0f`).
118+
- `float`. Sets the experience rewarded for smelting the given input. Requires greater than or equal to 0. (Default `0.1f`).
95119
96120
```groovy:no-line-numbers
97121
exp(float)
122+
experience(float)
123+
```
124+
125+
- `int`. Sets the time in ticks the recipe takes. Requires greater than or equal to 1. (Default `200`).
126+
127+
```groovy:no-line-numbers
128+
time(int)
98129
```
99130
100131
---
@@ -125,7 +156,7 @@ furnace.recipeBuilder()
125156
- Removes all recipes that match the given input:
126157

127158
```groovy:no-line-numbers
128-
furnace.removeByInput(ItemStack)
159+
furnace.removeByInput(IIngredient)
129160
```
130161
131162
- Removes all recipes that match the given output:
@@ -134,23 +165,49 @@ furnace.recipeBuilder()
134165
furnace.removeByOutput(IIngredient)
135166
```
136167
168+
- Removes the given recipe from the recipe list:
169+
170+
```groovy:no-line-numbers
171+
furnace.removeFuelConversion(CustomFurnaceManager.FuelConversionRecipe)
172+
```
173+
174+
- Removes all conversion recipes with the given smelted item:
175+
176+
```groovy:no-line-numbers
177+
furnace.removeFuelConversionBySmeltedStack(ItemStack)
178+
```
179+
137180
- Removes all registered recipes:
138181
139182
```groovy:no-line-numbers
140183
furnace.removeAll()
141184
```
142185
186+
- Removes all conversion recipes:
187+
188+
```groovy:no-line-numbers
189+
furnace.removeAllFuelConversions()
190+
```
191+
143192
:::::::::: details Example {open id="example"}
144193
```groovy:no-line-numbers
145-
furnace.removeByInput(item('minecraft:clay'))
194+
furnace.removeByInput(item('minecraft:clay:*'))
146195
furnace.removeByOutput(item('minecraft:brick'))
196+
furnace.removeFuelConversionBySmeltedStack(item('minecraft:sponge', 1))
147197
furnace.removeAll()
198+
furnace.removeAllFuelConversions()
148199
```
149200

150201
::::::::::
151202

152203
## Getting the value of recipes
153204

205+
- Iterates through every entry in the registry, with the ability to call remove on any element to remove it:
206+
207+
```groovy:no-line-numbers
208+
furnace.streamFuelConversions()
209+
```
210+
154211
- Iterates through every entry in the registry, with the ability to call remove on any element to remove it:
155212
156213
```groovy:no-line-numbers

docs/groovy-script/minecraft/helpers/game_rule.md

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,8 @@ GameRules are case-sensitive! Enable logging of new GameRules via `setWarnNewGam
2020
Refer to this via any of the following:
2121

2222
```groovy:no-line-numbers {2}
23-
gamerule
24-
game_rule/* Used as page default */ // [!code focus]
25-
gameRule
26-
GameRule
2723
minecraft.gamerule
28-
minecraft.game_rule
24+
minecraft.game_rule/* Used as page default */ // [!code focus]
2925
minecraft.gameRule
3026
minecraft.GameRule
3127
Minecraft.gamerule
@@ -60,12 +56,12 @@ mods.minecraft.GameRule
6056
- Sets if creating new GameRules logs a warning. Enable it if you need to check spelling/capitalization. Disabled by default:
6157

6258
```groovy:no-line-numbers
63-
game_rule.setWarnNewGameRule(boolean)
59+
minecraft.game_rule.setWarnNewGameRule(boolean)
6460
```
6561
6662
:::::::::: details Example {open id="example"}
6763
```groovy:no-line-numbers
68-
game_rule.setWarnNewGameRule(true)
64+
minecraft.game_rule.setWarnNewGameRule(true)
6965
```
7066

7167
::::::::::
@@ -75,19 +71,19 @@ game_rule.setWarnNewGameRule(true)
7571
- Adds a map of GameRule name to values:
7672

7773
```groovy:no-line-numbers
78-
game_rule.add(Map<String, String>)
74+
minecraft.game_rule.add(Map<String, String>)
7975
```
8076
8177
- Adds a new entry in the format `name`, `value`, with `value` being a String that can represent a number (`-1`, `5`) or boolean (`true`, `false`):
8278
8379
```groovy:no-line-numbers
84-
game_rule.add(String, String)
80+
minecraft.game_rule.add(String, String)
8581
```
8682
8783
:::::::::: details Example {open id="example"}
8884
```groovy:no-line-numbers
89-
game_rule.add(['mobGriefing': 'false', 'keepInventory': 'true'])
90-
game_rule.add('doDaylightCycle', 'false')
85+
minecraft.game_rule.add(['mobGriefing': 'false', 'keepInventory': 'true'])
86+
minecraft.game_rule.add('doDaylightCycle', 'false')
9187
```
9288

9389
::::::::::

0 commit comments

Comments
 (0)