|
| 1 | +--- |
| 2 | +title: Browsing the server.jar code |
| 3 | +description: Learn how to patch the server.jar and browse the source code. |
| 4 | +--- |
| 5 | + |
| 6 | +The ~~patcher~~ allows you to more easily prepare an environment for exploring the Hytale Server without publishing the decompiled code. |
| 7 | + |
| 8 | +## Setup |
| 9 | + |
| 10 | +- Clone the patcher `git clone https://github.com/HytaleModding/patcher.git`, and enter the directory. `cd patcher` |
| 11 | + |
| 12 | +- Create a Python virtual environment in the `.venv` folder. The command for this varies by platform but it is probably |
| 13 | + one of these: |
| 14 | + |
| 15 | + - `python -m venv .venv` |
| 16 | + - `python3 -m venv .venv` (Linux) |
| 17 | + - `py -3.13 -m venv .venv` (Windows) |
| 18 | + |
| 19 | + In the last one, specifying the version is recommended if you have multiple Pythons installed. |
| 20 | + |
| 21 | +- Activate the virtual environment: |
| 22 | + - Windows: `".venv\Scripts\activate"` (including the quotes) |
| 23 | + - Linux/Mac: `source .venv/bin/activate` |
| 24 | + - From now on, you are running python commands from inside the venv, hence you must use `python` instead of `py` or `python3` to invoke python. |
| 25 | + |
| 26 | +- Inside the venv, you have to install the dependencies |
| 27 | + - `pip install -r requirements.txt` |
| 28 | + |
| 29 | +- Install these dependencies and ensure they are on PATH: |
| 30 | + - `git` |
| 31 | + - `java` you need JDK 25 or newer |
| 32 | + - `jar` (comes with JDK inside the bin folder) |
| 33 | + - `mvn` |
| 34 | + |
| 35 | +## Usage |
| 36 | + |
| 37 | +Put your HytaleServer.jar in the same root directory of this repo or specify an environment variable `HYTALESERVER_JAR_PATH` with the path to your HytaleServer.jar |
| 38 | + |
| 39 | +Then run this: |
| 40 | + |
| 41 | +```shell |
| 42 | +python run.py setup |
| 43 | +``` |
| 44 | + |
| 45 | +It will |
| 46 | + |
| 47 | +- copy the HytaleServer.jar into `work/download` |
| 48 | + - (on Windows) fix `META-INF/license` name collision |
| 49 | +- decompile it using Fernflower and save the output to `work/decompile` |
| 50 | +- set up a Maven project in `hytale-server` with the decompiled code |
| 51 | + |
| 52 | +You can then open the `hytale-server` folder in your favorite IDE and begin exploring the code. For _IntelliJ IDEA_, |
| 53 | +you must first set up the SDK. After opening the project (you can open the `pom.xml` file, IDEA will prompt you to open |
| 54 | +the entire project) press Ctrl+Alt+Shift+S and under _Project_ configure SDK and Language level to _25_. |
| 55 | + |
| 56 | +If IDEA does not offer an option to run the main file, right-click the `src` folder -> Mark Directory As -> Sources Root |
| 57 | +then reload the maven project:\ |
| 58 | +\ |
| 59 | +It is located in the "m" icon on the right side:\ |
| 60 | +\ |
| 61 | +If you don't see it, enable it under View -> Tool Windows -> Maven.\ |
| 62 | + |
| 63 | + |
| 64 | +This decompiled code is likely broken. But it is somewhat usable for exploration. Try Ctrl+Shift+F and search PacketAdapters |
0 commit comments