Skip to content

Commit

Permalink
GroovyScript Vanilla Improvements (#26)
Browse files Browse the repository at this point in the history
* add modrinth links
* vanilla object mappers
* Add basic command support
* vanilla helper categories
* IIngredient docs
* order
* remove migrated helper file
* fix outdated examples links
* convert events to use index files
* rename events that are subclasses to only be subclass
* add spaces to event titles
* remove generic event todo file
* remove line numbers
* Resource Location
* fixing the broken links mhm yes
  • Loading branch information
WaitingIdly authored Oct 25, 2024
1 parent 3c501df commit a0a4f76
Show file tree
Hide file tree
Showing 380 changed files with 3,380 additions and 2,434 deletions.
2 changes: 1 addition & 1 deletion docs/groovy-script/content/creative_tab.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ You can get a creative tab by using
creativeTab(String tabName)
```

A list of existing creative tab names can be obtained by running the `/gs creativeTabs` command.
A list of existing creative tab names can be obtained by running the [`/gs creativeTabs` command](../minecraft/commands/index.md#creative-tabs).
2 changes: 1 addition & 1 deletion docs/groovy-script/getting_started/editors.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ There are two ways to start the language server.

1. Adding `-Dgroovyscript.run_ls=true` to the JVM arguments in your preferred launcher and start Minecraft with GroovyScript.
You will be able to connect to the language server as soon as GroovyScript has been loaded in the `FMLInitializationEvent` load step.
2. By starting Minecraft and GroovyScript and running the `/grs runLS` command.
2. By starting Minecraft and GroovyScript and running the [`/grs runLS` command](../minecraft/commands/index.md#language-server).
As commands can only be run in-game, you will obviously need to load into a world for that.

You can check if the server started by checking for a `Starting Language server` message in the `groovy.log` file.
Expand Down
8 changes: 8 additions & 0 deletions docs/groovy-script/getting_started/groovy_log.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ The file is always `[Minecraft instance path]/logs/groovy.log` for clients
and `[Minecraft instance path]/logs/groovy_server.log` for servers.


## Clean Reloading

When the [`/gs reload` command](../minecraft/commands/index.md#reload) is run to [reload](./reloading.md)
the `postInit` script files, you can pass `--clean` as an argument to remove the previously logged information.

This can help improve readability of the log file, yet may hide errors that still have an impact on your game.


## Interacting


Expand Down
8 changes: 1 addition & 7 deletions docs/groovy-script/getting_started/object_mappers.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,4 @@ Currently, the best way to observe what Object Mappers will do is to use the Lan

:::

- [IIngredient](../minecraft/ingredient.md)

- [ItemStack](../minecraft/item.md)

- [OreDict](../minecraft/ore_dictionary.md)

- [Resource Location](../minecraft/resource_location.md)
- [All Vanilla Object Mappers](../minecraft/vanilla_object_mappers.md)
8 changes: 7 additions & 1 deletion docs/groovy-script/getting_started/reloading.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,16 @@ Some compat may not properly implement reloading, and will not be reloaded prope

To reload GroovyScript, either:

- Run the `/gs reload` command
- Run the [`/gs reload` command](../minecraft/commands/index.md#reload)
- Use the keybind, by default bound to `CTRL+R`


## Command

The [`/gs reload` command](../minecraft/commands/index.md#reload) can also be passed the argument `--clean`.
This will delete the existing text in the [`groovy.log`](./groovy_log.md)


## Class Caching

For performance reasons, script classes are cached.
Expand Down
1 change: 1 addition & 0 deletions docs/groovy-script/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Are you not seeing what other see on this wiki? Try reloading it.

GroovyScript can be downloaded on
- [CurseForge](https://www.curseforge.com/minecraft/mc-mods/groovyscript)
- [Modrinth](https://modrinth.com/mod/groovyscript)
- [GitHub](https://github.com/CleanroomMC/GroovyScript/releases)

## Features
Expand Down
138 changes: 138 additions & 0 deletions docs/groovy-script/minecraft/commands/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@

# Commands

GroovyScript adds a large number of commands to aid in developing.

Any of these commands can be run via using `/gs`, `/grs`, or `groovyscript` interchangeably.
`/gs` will typically be used as it is the shortest.


## Language Server

- `/gs runLS`
- `/gs runLanguageServer`

The [Language Server](../../getting_started/editors.md) can be started in multiple ways, one of which being this command.


## Reload

- `/gs reload`

You can [reload](../../getting_started/reloading.md) the GroovyScript `postInit` files
via this command or via a keybind.

Running `/gs reload --clean` will clean up the [log](../../getting_started/groovy_log.md) file
and remove all prior text.

This can make it more readable and easier to identify errors with the current script instead of seeing
all errors that have been experienced iin this minecraft session.
These errors will still impact the game.

## Clean Log

- `/gs cleanLog`

Additionally, cleaning the [log](../../getting_started/groovy_log.md) file can be done directly.


## Check

- `/gs check`

Parses all script files to ensure the syntax is valid.
This will not identify dynamic errors, such as those from [Object Mappers](../../getting_started/object_mappers.md) or calling methods.


## [Info](./info.md)

- [`/gs info`](./info.md#info)
- [`/gs hand`](./info.md#hand)
- [`/gs looking`](./info.md#looking)
- [`/gs self`](./info.md#self)

There are a large number of possible arguments for each of these commands.

The most important set of commands are the set of [Info Commands](./info.md),
which will help you get data from the game into a GroovyScript format.


## Log

- `/gs log`

Prints the location of the GroovyScript log file and Minecraft log file to the chat.
The locations are copyable.


## Wiki

- `/gs wiki`
- `/gs doc`
- `/gs docs`
- `/gs documentation`

Prints a link to this [wiki](../../index.md) to the chat.


## Packmode

- `/gs packmode`

If packmodes are enabled, you can pass in an argument setting the packmode.


## Generate Wiki

- `/gs generateWiki`
- `/gs generateDoc`
- `/gs generateDocs`
- `/gs generateDocumentation`

Generates the wiki files for all mods installed in the pack.

These files will be generated from the source code of the mods, and so will be relevant and accurate to your pack,
regardless of any updates that happen afterwards.

It will also print a link to the wiki folder to the chat.


## Generate Examples

- `/gs generateExamples`

::: info Warning {id="warning"}

Currently, generating the example files can replace already existing files.
Ensure that you have your files backed up or in a subfolder to avoid this.

:::

Generates the examples files for all mods installed in the pack.

This can be extremely useful for seeing actual examples of recipes being changed for the mods that you have installed.

These files will be generated from the source code of the mods, and so will be relevant and accurate to your pack,
regardless of any updates that happen afterwards.

It will also print a link to the examples folder to the chat.


## Creative Tabs

- `/gs creativeTabs`

This will print every Creative Tab that has been registered to the chat
and the the `groovy.log` file.

It will also print the location of the GroovyScript log file to the chat.


## Delete Script Cache

- `/gs deleteScriptCache`

In order to improve the speed of loading scripts, GroovyScript [caches the script files](../../getting_started/reloading.md#class-caching).

Sometimes this can error, and classes will not be reloaded properly.
In this situation, running this command will delete the cache and force it to be entirely re-evaluated.
103 changes: 103 additions & 0 deletions docs/groovy-script/minecraft/commands/info.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@

# Info Commands

GroovyScripts adds multiple commands to retrieve information from the game.

The primary purpose is to convert components in the game into GroovyScript [Object Mappers](../../getting_started/object_mappers.md).

Each command processes through information via the same steps:
- Collecting information from the world, which is done by the command directly and varies by command.
- Parsing this information via the `InfoParserRegistry` and all valid `InfoParser`s,
depending on arguments passed into the command.
- Printing the output information to the chat, or an error if nothing was found.


## Syntax

Each type of info command can be used with different arguments

There are two basic arguments:

- `all`: Ignores any arguments allowing only a specific argument to be used.
- `pretty`: Some info types may have different ways in which they will be logged if pretty is true -
in particular, NBT Data will appear significantly differently when enabled.

And there are a large and variable number of more complex arguments:

Any `InfoParser` key can be used to filter the valid outputs.
This can be done in two ways,
- allow: using the key directly will cause the command to only print the `InfoParser`s matching the input keys.
- negate: using the key prefixed by a minus sign `-` will cause the command to skip matching `InfoParser`s.


::: info External Compat {id="note"}

Note that `InfoParser`s do *not* have this filtering logic enforced, and may not implement this correctly.

:::

## Command Options

### Info

- `/gs info`

Runs the info operation on the first valid type from Hand, Looking, or Self types.


### Hand

- `/gs hand`

Runs the info operation on the ItemStack in your hand.

Particularly useful for getting the [`EntityEntry`](../vanilla_object_mappers.md#entity) or [`IBlockState`](../vanilla_object_mappers.md#blockstate)
Object Mappers.

### Looking

- `/gs looking`

Runs the info operation on the Entity or Block you are looking at, prioritizing entities.

Target must be in range to be detected.

Particularly useful for getting the [`EntityEntry`](../vanilla_object_mappers.md#entity) or [`IBlockState`](../vanilla_object_mappers.md#blockstate)
Object Mappers.

### Self

- `/gs self`

Runs the info operation on the player entity executing the command.

Particularly useful for getting the [`Dimension`](../vanilla_object_mappers.md#dimension), [`Biome`](../vanilla_object_mappers.md#biome),
or [`Potion`](../vanilla_object_mappers.md#potion) Object Mappers.


## Vanilla Info Parsers

- [`biome`](../vanilla_object_mappers.md#biome): Biome the the target is in.
- [`block`](../vanilla_object_mappers.md#block): Block being targeted or representing the held item.
- [`blockstate`](../vanilla_object_mappers.md#blockstate): IBlockState being looked at or representing the held item.
- [`creativetab`](../vanilla_object_mappers.md#creativetab): Creative Tab the targeted ItemStack is contained by, if any.
- [`dimension`](../vanilla_object_mappers.md#dimension): Dimension type the player is in.
- [`enchantment`](../vanilla_object_mappers.md#enchantment): Enchantments on the held ItemStack.
- [`entity`](../vanilla_object_mappers.md#entity): Entity being looked at.
- [`fluid`](../vanilla_object_mappers.md#liquid-and-fluid): Fluid being looked at in world or being contained in the item being held.
- [`item`](../vanilla_object_mappers.md#itemstack): ItemStack in the player's main hand, offhand, or representing the block being looked at.
- [`nbt`](../vanilla_object_mappers.md#nbt): NBT data of target, trimmed if it gets too long.
- [`oredict`](../vanilla_object_mappers.md#ore): Ore Dictionary values the held ItemStack is part of.
- `potioneffect`: Potion Effects for the held item, active potion effects for the entity being looked at, or active potion effects on the player.
- `translation`: Translation key for the target.
- [`villagercareer`](../vanilla_object_mappers.md#career): The Villager Career of the villager being targeted.
- [`villagerprofession`](../vanilla_object_mappers.md#profession): The Villager Profession of the villager being targeted.


## Creating Info Parsers

In order to register an `InfoParser`, the only thing that needs to be done
is to implement the `InfoParser` interface and call `InfoParserRegistry#addInfoParser(InfoParser)`.

However, the abstract class `GenericInfoParser` has a number of helpful methods already created
to make creating complex `InfoParser`s easy, so extending that should be preferred.
Loading

0 comments on commit a0a4f76

Please sign in to comment.