Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Kenny-Hui committed Jan 31, 2024
1 parent c2ab270 commit 792b175
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 24 deletions.
8 changes: 5 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ Thanks for considering to contribute to Joban Client Mod, below you'll find some
Submitting a bug report is a great way to put lights on the issue you noticed that are not behaving correctly.

## Documentation
All information and documentation regarding JCM is located on our [wiki](https://www.joban.tk/wiki/JCM:Joban_Client_Mod), if you would like to update or add any informations, you should go there instead.
All information and documentation regarding JCM is located on our [wiki](https://www.joban.tk/wiki/JCM:Joban_Client_Mod), if you would like to update or add any information, you can create an account there and start modifying!

## Translation
We currently provide official translations for **English**, **Chinese (Simplified)** and **Chinese (Traditional)**. Other translations are not officially maintained, but you may contribute by forking this project, adding the necessary translation files and submit a pull request here.
We currently provide official translations for **English**, **Chinese (Simplified)** and **Chinese (Traditional)**.
Other translations are not officially maintained, but you may contribute by forking this project, adding the necessary translation files and submit a pull request here.

The English translation file (Which is usually the most up-to-date) is located in `fabric/src/main/resources/assets/jsblock/lang/en_us.json`, you may use that as a base and translate it to other languages.
The English translation file (The most up-to-date) is located in `fabric/src/main/resources/assets/jsblock/lang/en_us.json`, you may use that as a base and translate it to other languages.
Text does not have to be translated literally, as long as the original meaning are not lost.

## Code
See [Contribute Code](./docs/Contribute_Code.md)
4 changes: 4 additions & 0 deletions CONTRIBUTING_PROJ.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Contributing - Make changes to project
If you would like to make changes directly in the JCM repository, this is the right page! You'll find step by step instructions below.

*To be done =w=*
38 changes: 17 additions & 21 deletions docs/Contribute_Code.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,38 @@
**Note: Work In progress, many things are probably subject to change**

## Project Structure
Due to our rather complex requirements of having to support Fabric/Forge 1.16.5 - 1.20.4, we use the Minecraft-Mappings project to facilitate building lots of variants with a single codebase.
Due to our rather complex requirements of having to support Fabric/Forge 1.16.5 - 1.20.*, we use the Minecraft-Mappings project to facilitate building lots of variants with a single codebase.

The primary development happens on Fabric, as such almost all the assets and codes are located in the `fabric` folder.
The main mod's code are located in `fabric/src/main/java/com/lx862/jcm/mod`, these files will be compiled by both fabric and forge.
The assets are located in `fabric/src/main/resources/assets/jsblock`, these files are also used by both fabric and forge.
Anything other than that is modloader specific.
Anything other than that is mod-loader specific.

When compiling Forge builds, the common code part (`fabric/src/main/java/com/lx862/jcm/mod`) will be copied over from the fabric folder to the forge folder for compilation.

## Minecraft Mappings
**Minecraft Mappings** is a project that allows cross version (1.16.5+) and modloader compatibility with 1 single codebase.
The very basic idea is that **you don't use Minecraft's code**, instead use all the wrapper classes/method provided by **Minecraft Mappings**. (Which *usually* has the same name as Yarn mapping, under the `org.mtr.mapping` package)
## Introduction to Minecraft Mappings
**Minecraft Mappings** is a project that allows cross version (1.16.5+) and mod-loader compatibility with 1 single codebase.
The basic idea is that *you don't use Minecraft's code*, instead use all the wrapper classes/method provided by **Minecraft Mappings**. (Which *usually* has the same name as Yarn mapping, under the `org.mtr.mapping` package)

**Minecraft Mappings** will generate artifacts as a jar for each version and modloader, they all have the same classes/method, and only the underlying implementation is changed to adapt to different Minecraft versions, as such nothing needs to be changed when compiling to each Minecraft version.
**Minecraft Mappings** are generated as a jar for each Minecraft version and mod-loader, where they all have the same classes/method, and only the underlying implementation is changed to adapt to different Minecraft versions, as such nothing needs to be changed when compiling to each Minecraft version.

Note that not all method and classes can be mapped, for example one method could exist in 1.18.2 but not 1.17.1.
As such, method that are guaranteed to exist across all version will be annotated with `@MappedMethod`, whereas other method that may not exist across all versions and modloaders will be annotated with `@Deprecated` (In which your IDE should give you a warning), don't use anything that's marked as deprecated as they may fail to compile acoss all versions and platform.
As such, method that are guaranteed to exist across all version will be annotated with `@MappedMethod`, whereas other method that may not exist across all versions and mod-loaders will be annotated with `@Deprecated` (In which your IDE should give you a warning), don't use anything that's marked as deprecated as they may fail to compile across all versions and platform.
When overriding method on classes provided by **Minecraft Mappings**, you should be overriding and calling methods made by Minecraft-Mappings (Sometimes named like `methodName2` or `methodName3`), these are methods provided by **Minecraft Mappings**, whereas `methodName` is usually the underlying method provided by Minecraft.

Also when overriding method on classes provided by **Minecraft Mappings**, you should be overriding and calling methods named like `methodName2` or `methodName3`, these are methods provided by **Minecraft Mappings**, whereas `methodName` is for example, the underlying method provided by Minecraft.

### Ok but Minecraft Mappings does not contain the code I want
To be done. TL;DR use the manifold preprocessing, or contribute the code mappings directly to upstream.
**Minecraft Mappings** also provide helper classes (For example the Vanilla Registry) on components with radical changes between versions.
### What if Minecraft Mappings doesn't contain the code I want
In general there are 2 options:
1. Contribute to [Minecraft-Mappings](https://github.com/Minecraft-Transit-Railway/Minecraft-Mappings) by following the instruction there.
2. A backup solution is using manifold preprocessing to conditionally apply code (To be continued....)

### What about RenderSystem?
Not all Minecraft's code are obfuscated, for example some of the code in `com.mojang.blaze3d` including RenderSystem is not obfuscated, a mapping like Yarn or Mojmap is not needed and there's a much less chance that the method name will differ across modloaders due to them using different mappings.

If you really find yourself not being able to compile across all versions and modloaders when using code that's not provided by Minecraft Mappings, again follow the steps above.
Not all Minecraft's code are obfuscated, for example some of the code in `com.mojang.blaze3d` including RenderSystem is not obfuscated, a mapping like Yarn or Mojmap is not needed and there's a much less chance that the method name will differ across mod-loaders due to them using different mappings.
If you really find yourself not being able to compile across all versions and mod-loaders when using code that's not provided by Minecraft Mappings, you can follow the section above.

## Code Guidelines
### Naming Convention
Use Java naming convention (TLDR: InterfaceName, ClassName, fieldName, methodName)

### Error handling
Don't just try/catch e.printStackTrace() and move on, not everyone stares at the console when playing.

At best user will report the stacktrace in the console to you, you found and fixed the issues.
At worst, you'll run into state issues leading to crash that are entirely unrelated to the things you should be looking for, have part of your functonality simply "broken" and potentially dropping the client performance if the code just errors out every frame.

To be continued...
### Exception handling
If you do not have any plan to handle the exception appropriately (Other than logging), you should just not try/catch and let the parent class handle the exception.

0 comments on commit 792b175

Please sign in to comment.