Skip to content

Commit

Permalink
Merge pull request #31 from Niels-NTG/v1.5
Browse files Browse the repository at this point in the history
GDMC-HTTP v1.5
  • Loading branch information
Niels-NTG authored Aug 21, 2024
2 parents dff89a4 + 809eb3c commit 9c564a9
Show file tree
Hide file tree
Showing 55 changed files with 1,562 additions and 796 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ build
eclipse
run
mcmodsrepo
buildAllJars

logo-design

# profiler
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# GDMC-HTTP 1.5.0 (Minecraft 1.19.2 + 1.20.2)

- NEW: GDMC-HTTP is now compatible with both the Forge and Fabric modding platform!
- NEW: `GET /heightmap` can now receive a list of [block IDs](https://minecraft.wiki/w/Java_Edition_data_values#Blocks), [block tag keys](https://minecraft.wiki/w/Tag#Block_tags_2) and [fluid tag keys](https://minecraft.wiki/w/Tag#Fluid_tags) to create your own custom heightmaps!
- NEW: `GET /heightmap` can now receive an upper and lower Y-value limit for the requested heightmap. Usefull for taking measurements of the surface of caves or The Nether dimension.
- NEW: Add `keepLiquids` flag to `POST /structure` endpoint. When set to `false` it removes all water sources present at the placement locations of the to be placed structure.
- FIX: Actually implement behaviour to prevent spawning drops when placing structures for the `spawnDrops` flag of the `POST /structure` endpoint.
- FIX: `/commands` now returns a 405 is any other HTTP method besides `POST` is used.

# GDMC-HTTP 1.4.6 (Minecraft 1.19.2 + 1.20.2)

- NEW: To enhance backwards compatibility, all features introduced in GDMC-HTTP 1.4.0 are now also available for Minecraft 1.19.2!
Expand Down
40 changes: 18 additions & 22 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,25 @@ Code contributions are more than welcome. We do however strongly recommend to fi

If you want to contribute to the development of the HTTP interface mod, or are just interested how it works under the hood, you can also download the source code and run the mod from the source.

These instructions are adapted from the [Forge installation guide](https://docs.minecraftforge.net/en/1.20.x/gettingstarted/#getting-started-with-forge).

## Get the sources

Clone (or fork and clone) this repository to your machine.

## Choose your IDE:

- Forge explicitly supports developing with IntelliJ or Eclipse environments, but any environment, such as Netbeans, Visual Studio Code to vi/emacs, can be made to work.
- For both Intellij IDEA and Eclipse their Gradle integration will handle the rest of the initial workspace setup, this includes downloading packages from Mojang, MinecraftForge, and a few other software sharing sites.
- We would personally recommend using [IntelliJ IDEA](https://www.jetbrains.com/idea/) for development. This is an IDE specialised for Java development that's very advanced while also easy to get started with. Additionally, this IDE supports the [Minecraft NBT Support](https://plugins.jetbrains.com/plugin/12839-minecraft-nbt-support) plugin which makes it easy to inspect [NBT files](https://minecraft.wiki/w/NBT_format) as well as [Manifold](https://plugins.jetbrains.com/plugin/10057-manifold) (more on that later).
- For both Intellij IDEA and Eclipse their Gradle integration will handle the rest of the initial workspace setup, this includes downloading packages from Mojang, Fabric, Forge and other dependencies.
- For most, if not all, changes to the `build.gradle` or `gradle.properties` file to take effect Gradle will need to be invoked to re-evaluate the project, this can be done through Refresh buttons in the Gradle panels of both the previously mentioned IDEs.

We would personally recommend using [IntelliJ IDEA](https://www.jetbrains.com/idea/) for development. This is an IDE specialised for Java development that's very advanced while also easy to get started with. Additionally this IDE supports the [Minecraft NBT Support](https://plugins.jetbrains.com/plugin/12839-minecraft-nbt-support) plugin which makes it easy to inspect [NBT files](https://minecraft.wiki/w/NBT_format) as well as [Manifold](https://plugins.jetbrains.com/plugin/10057-manifold) (more on that later).

To aid in debugging the HTTP requests we recommend an API development and test tool such as [Insomnia](https://insomnia.rest/).

## Generating IDE Launch/Run Configurations:

- For IntelliJ, run the `genIntellijRuns` gradle task (gradlew `genIntellijRuns`). This will generate the Run Configurations and download any required assets for the game to run. After this has finished, reload the project from disk and click on "Add configuration". Under the "Application" tab, you have a `runClient` configuration. Select it, and edit your Configurations to fix the “module not specified” error by changing selecting your “main” module. You can now run Minecraft, with the mod loaded in. Make sure to open a Minecraft world before testing the mod.
- For Eclipse, run the `genEclipseRuns` gradle task (gradlew `genEclipseRuns`). This will generate the Launch Configurations and download any required assets for the game to run. After this has finished refresh your project.
To aid in debugging the HTTP requests we recommend an API testing tool such as [Kreya](https://kreya.app), [Yaak](https://yaak.app) or a command line tool such as `cURL` or `wget`.

# Supporting multiple Minecraft versions

We try to make GDMC-HTTP both backwards and forwards compatible such that client programs that interface with GDMC-HTTP from prior GDMC years can work with newer versions of the game and visa versa. Therefore we try to support multiple versions of Minecraft.
We try to make GDMC-HTTP both backwards and forwards compatible such that client programs that interface with GDMC-HTTP from prior GDMC years can work with newer versions of the game and vice versa. Therefore, we try to support multiple versions of Minecraft.

One potential way of doing this is creating a branch any time a new feature or patch has been added which backports these to older versions of the game. This can be quite time-consuming and can easily lead to missing features. Not to mention a lot of merge conflicts.

Instead we've taken inspiration from the build setup of the [Distant Horizons mod](https://gitlab.com/jeseibel/distant-horizons). Using this setup we can support multiple Minecraft versions and even multiple modding frameworks (all though we will stick with only supporting Forge for now) on the same branch. The "secret ingredient" here is the [Manifold Preprocessor](https://github.com/manifold-systems/manifold/tree/master/manifold-deps-parent/manifold-preprocessor), a dependency that adds conditional compilation to Java somewhat reminiscent of C. These directives can be placed anywhere in the code. The symbols are set by the `writeBuildGradlePredefine` function in `build.gradle`, which generates the `build.properties` which defines the list of symbols. Here are some examples on how it can be used in the source code:
Instead, we've taken inspiration from the build setup of the [Distant Horizons mod](https://gitlab.com/jeseibel/distant-horizons). Using this setup we can support multiple Minecraft versions and even multiple modding frameworks on the same branch. The "secret ingredient" here is the [Manifold Preprocessor](https://github.com/manifold-systems/manifold/tree/master/manifold-deps-parent/manifold-preprocessor), a dependency that adds conditional compilation to Java somewhat reminiscent of C. These directives can be placed anywhere in the code. The symbols are set by the `writeBuildGradlePredefine` function in `build.gradle`, which generates the `build.properties` which defines the list of symbols. Here are some examples on how it can be used in the source code:

```java
#if (MC_VER == MC_1_19_2)
Expand All @@ -53,25 +44,33 @@ blockState.blocksMotion()

You may need to install a [plugin](https://plugins.jetbrains.com/plugin/10057-manifold) for your IDE for it to apply syntax highlighting and understand how to evaluate these directives.

All Gradle tasks such as `publish` and `runClient` can only run for one Minecraft version at the time. This target version is defined using the `targetMinecraftVersion` property in the `gradle.properties` file. You may change this value to your target version during development, but please revert it to the newest version supported by GDMC when you're done. The specific versions we support are listed in the `versionProperties` folder, in which you will find a file with properties specific for that version of the game and modding framework. To compile `jar` files for all these versions in a single action, run `buildAll.sh` script. You can find the output files in the `mcmodsrepo/` folder.
All Gradle tasks such as `publish` and `runClient` can only run for one Minecraft version at the time. This target version is defined using the `targetMinecraftVersion` property in the `gradle.properties` file. You may change this value to your target version during development, but please revert it to the newest version supported by GDMC when you're done. The specific versions we support are listed in the `versionProperties` folder, in which you will find a file with properties specific for that version of the game and modding framework. To compile `jar` files for all these versions in a single action, run `buildAll.sh` script. You can find the output files in the `buildAllJars/` folder.

# Supporting multiple mod loaders

We support multiple modding frameworks (currently Fabric and Forge) using a project setup inspired by [Distant Horizons mod](https://gitlab.com/jeseibel/distant-horizons). This includes a script `buildAll.sh` which for each Minecraft version creates a single `.jar` file which is compatible with all the mod loaders we support.

For this we try to avoid using APIs specific to any mod loader as much as possible so the vast majority of code can be shared across all modding frameworks. You will find this code in the `common` namespace, while code specifically for mod loaders such as entry points and lifecycle event listeners are under the namespace of the mod loader name (`fabric`, `forge`).

The IDE has separate Gradle tasks for each mod loader. The most important of which are `Fabric Client (:fabric)` and `Forge Client (:forge)`, which builds and runs the mod in a Minecraft client with the relevant mod loader.

# Update version checklist

## Updating GDMC-HTTP

Our version numbers follow follow the [Semantic Versioning schema](https://semver.org/).
Our version numbers follow the [Semantic Versioning schema](https://semver.org/).

1. When you have picked the appropriate version number set the `mod_version` property in `gradle.properties` to this value.
2. Find-and-replace the previous version number with the new one in the documentation. This includes the following places:
- In the versions table in `README.md`, which has a link to the release page and the API docs page which includes the version tag in the text and URL.
- The heading at the top of `docs/Endpoints.md`.
- The example output of the `OPTIONS /` endpoint as documented in `docs/Endpoints.md` needs to be updated to match the new output.
3. Update `CHANGELOG.md` with an list of items that are `NEW:`, `FIX:` and/or `BREAKING:`.
3. Update `CHANGELOG.md` with a list of items that are `NEW:`, `FIX:` and/or `BREAKING:`.
4. When relevant, update documentation.
5. Run the `buildAll.sh` script to build `jar` files for each supported Minecraft version/modding framework.
6. Do some final (manual) tests, preferably on all supported Minecraft/modding framework versions.
7. Commit all relevant changes, including everything we did in the previous steps.
8. Tag this commit with `v<newVersionNumber>` (eg. `v1.4.6`).
8. Tag this commit with `v<newVersionNumber>` (e.g. `v1.5.0`).
9. Push the commit and the tag.
10. Draft a new release on GitHub. Paste the items for this version from the changelog into the release notes section. Upload the jar files for this version for each Minecraft/modding framework we support.
11. Inform the people on the GDMC Discord about the update.
Expand All @@ -81,7 +80,4 @@ Our version numbers follow follow the [Semantic Versioning schema](https://semve

Of each minor version of Minecraft we tend to only support one version. Depending on how the timeline of Minecraft's release schedule and GDMC lines up, we pick the most recent version of the game and wait for a few patches to have rolled out. This is then set as the target version for the coming GDMC Settlement Generation Challenge.

To start supporting a new version of Minecraft, first check if there is a stable version of a relevant modding framework (eg. Forge, NeoForged) that supports this version. If so, create a new file in the `versionProperties` folder named `<mcVersion>.properties` (eg.` 1.20.2.properties`). This file contains properties relevant for this specific version of the game, including the version of the modding framework. You can find listings of releases of Forge [here](https://files.minecraftforge.net/net/minecraftforge/forge/). Prefer using the "Recommended" version that matches the relevant version of Minecraft. Don't forget the set the `targetMinecraftVersion` property in the `gradle.properties` file to your new Minecraft version. After all this is done, reload your Gradle project and run `genIntellijRuns` (or `genEclipseRuns`) so all relevant dependencies are installed.



To start supporting a new version of Minecraft, first check if there is a stable version of a relevant modding framework (e.g. Fabric, Forge) that supports this version. If so, create a new file in the `versionProperties` folder named `<mcVersion>.properties` (eg.` 1.20.2.properties`). This file contains properties relevant for this specific version of the game, including the version of the modding framework. Prefer using the "Recommended" version that matches the relevant version of Minecraft. Don't forget the set the `targetMinecraftVersion` property in the `gradle.properties` file to your new Minecraft version. Then reload Gradle so the IDE can set up the environment.
Loading

0 comments on commit 9c564a9

Please sign in to comment.