Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'
cache: gradle
- name: Setup Gradle
Expand All @@ -29,16 +29,8 @@ jobs:
run: |
git config --global user.email "60985521+KaiAF@users.noreply.github.com"
git config --global user.name "iris"
- name: Run Init
run: node init.js
git submodule update --init --recursive
- name: Create dish workspace & patch
run: node ./dish/index.js
- name: "Clone Bundler"
uses: actions/checkout@v3
with:
token: ${{ secrets.PAT }}
repository: KaiAF/Dish-Bundler
path: Dish-Bundler
ref: main
- name: Compile dish
run: node ./dish/compile.js
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ repositories {
}

dependencies {
compileOnly("net.ouja:api:1.20.6-R0.1-SNAPSHOT")
compileOnly("net.ouja:api:1.21.8-R0.2-SNAPSHOT")
implementation 'it.unimi.dsi:fastutil:8.5.12'
}
```
Expand All @@ -41,7 +41,7 @@ Maven
<dependency>
<groupId>net.ouja</groupId>
<artifactId>api</artifactId>
<version>1.20.6-R0.1-SNAPSHOT</version>
<version>1.21.8-R0.2-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
4 changes: 2 additions & 2 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const fs = require('fs');

const colors = require('./libs/colors');

const DEFAULT_MINECRAFT_VERSION = "snapshot/23w51b";
const DEFAULT_MINECRAFT_VERSION = 'release/1.21.8';

function log(msg) {
console.log(`[Info]${colors.reset} ${msg}`);
Expand Down Expand Up @@ -79,7 +79,7 @@ function cacheExpired(pathToFile, MAX_CACHE_TIME_DAYS = 1) {
* @returns {Boolean} true if matches
*/
function checkMinecraftVersion(version) {
return /(^release\/([0-9]\.[1-3][0-9]\.[0-9]))$|(^snapshot\/([1-3][0-9]w[0-9][0-9][a-z])$)|(^pre\/([0-9]\.[1-3][0-9]\.[0-9]\-pre[0-9])$)/g.test(version);
return /(^release\/([0-9]\.[1-3][0-9](?:\.[0-9])|[0-9]\.[1-3][0-9]))$|(^snapshot\/([1-3][0-9]w[0-9][0-9][a-z])$)|(^pre\/((?:[0-9]\.[1-3][0-9]\.[0-9])|(?:[0-9]\.[1-3][0-9]))\-pre[0-9]$)/g.test(version);
}

module.exports = {
Expand Down
18 changes: 9 additions & 9 deletions dish/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const stdio = [process.stdin, process.stdout, process.stderr];
return process.exit(1);
}

const version = fs.readFileSync('dish/workspace/src/main/java/net/minecraft/DetectedVersion.java').toString().split('this.name = "')[1].split('"')[0];
const version = fs.readFileSync('dish/workspace/src/main/java/net/minecraft/SharedConstants.java').toString().split('VERSION_STRING = "')[1].split('"')[0];
log(`Found version '${version}'`);
if (!fs.existsSync(`cache/${version}`)) {
error(`Missing cache for version '${version}'`);
Expand Down Expand Up @@ -70,7 +70,7 @@ const stdio = [process.stdin, process.stdout, process.stderr];
createClassPath(version);
fs.writeFileSync('Dish-Bundler/libs/META-INF/main-class', 'net.minecraft.server.Main');
log('Getting version.json');
execSync(`cd cache/${version} && jar xf server-${version}.jar version.json`, { stdio });
execSync(`cd cache/${version} && jar xf server.jar version.json`, { stdio });
const VERSION = JSON.parse(fs.readFileSync(`cache/${version}/version.json`).toString());
VERSION.build_time = new Date();
VERSION.dishVersion = dishVersion;
Expand All @@ -91,21 +91,21 @@ const stdio = [process.stdin, process.stdout, process.stderr];

function remapServer(version) {
let mappings = fs.readFileSync(`cache/${version}/mappings.txt`).toString();
mappings = mappings.replace('net.minecraft.Util$10 -> ac$2:', 'net.minecraft.Util$2 -> ac$2:');
mappings = mappings.replace('net.minecraft.Util$11 -> ac$3:', 'net.minecraft.Util$3 -> ac$3:');
mappings = mappings.replace('net.minecraft.Util$2 -> ac$4:', 'net.minecraft.Util$4 -> ac$4:');
mappings = mappings.replace('net.minecraft.Util$10 -> ag$2:', 'net.minecraft.Util$2 -> ag$2:');
mappings = mappings.replace('net.minecraft.Util$11 -> ag$3:', 'net.minecraft.Util$3 -> ag$3:');
mappings = mappings.replace('net.minecraft.Util$2 -> ag$4:', 'net.minecraft.Util$4 -> ag$4:');
fs.writeFileSync(`cache/${version}/mappings.txt`, mappings);
log('Remapped mappings');
const jarName = fs.readdirSync('dish/workspace/build/libs').filter(f => f.startsWith('DishMC-' + version) && f.endsWith('.jar'))[0];
const jarName = fs.readdirSync('dish/workspace/build/libs').filter(f => f.toLowerCase() === 'dishmc-' + version + '.jar')[0];
if (!jarName) return error(`Could not find jar '${jarName}'`);
execSync(`java -jar libs/specialsource.jar -i dish/workspace/build/libs/${jarName} -o server-${version}-dirty.jar -m cache/${version}/mappings.txt --reverse`, { stdio });
}

function readLibraries(version) {
log('Reading libraries');
let libraries_list = '';
if (!fs.existsSync(`cache/${version}.json`)) return error('Could not find dependencies json file!');
const version_meta = JSON.parse(fs.readFileSync(`cache/${version}.json`).toString());
if (!fs.existsSync(`cache/${version}/${version}.json`)) return error('Could not find dependencies json file!');
const version_meta = JSON.parse(fs.readFileSync(`cache/${version}/${version}.json`).toString());
const dish_meta = JSON.parse(fs.readFileSync(`dish/libraries/${version}.json`).toString());
/**
* Minecraft Libraries
Expand Down Expand Up @@ -146,7 +146,7 @@ function readVersions(version) {

function createClassPath(version) {
log('Creating classpath-joined');
const version_meta = JSON.parse(fs.readFileSync(`cache/${version}.json`).toString());
const version_meta = JSON.parse(fs.readFileSync(`cache/${version}/${version}.json`).toString());
const libraries = version_meta.libraries.map(v => 'libraries/' + v.downloads.artifact.path);
libraries.push(`versions/${version}/server-${version}.jar`);
fs.writeFileSync('Dish-Bundler/libs/META-INF/classpath-joined', libraries.join(';'));
Expand Down
83 changes: 64 additions & 19 deletions dish/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@

const args = process.argv.slice(2);
const fs = require('fs');
const calculateFileHash = require('../utils/checkFileHash');
const https = require('https');
const { error, DEFAULT_MINECRAFT_VERSION, log, warn } = require('../config');
const { execSync } = require('child_process');
const calculateFileHash = require('../utils/checkFileHash');
const init = require('../utils/init');

const stdio = [process.stdin, process.stdout, process.stderr];
const DECOMPILE_VERSION = args[0] ?? DEFAULT_MINECRAFT_VERSION;
Expand All @@ -30,34 +32,30 @@ function parseLibraries(libraries) {
}

(async function () {
if (!fs.existsSync('init.js')) return error('Run this file in the parent directory');
if (!fs.existsSync('./utils/init.js')) return error('Run this file in the parent directory');
if (!fs.existsSync(`cache/${DECOMPILE_VERSION.split('/')[1]}/META-INF/libraries.list`)) {
warn(`Could not find file: cache/${DECOMPILE_VERSION.split('/')[1]}/META-INF/libraries.list, installing...`);
await cacheServer();
// final check
if (!fs.existsSync(`cache/${DECOMPILE_VERSION.split('/')[1]}/META-INF/libraries.list`)) {
error(`Could not find file: cache/${DECOMPILE_VERSION.split('/')[1]}/META-INF/libraries.list`);
return process.exit(1);
}
}

log(`Creating workspace for version '${DECOMPILE_VERSION}'`);
if (!fs.existsSync(`workspaces/${DECOMPILE_VERSION.split('/')[1]}`)) {
// If workspace does not exist, try to create it.
// If it fails, error out
warn(`Workspace for version '${DECOMPILE_VERSION.split('/')[1]}' wasn't found. Running init.js in 5 seconds...`);
setTimeout(() => {
try {
execSync(`node init.js --MC="${DECOMPILE_VERSION}" --OLD_MC="${args[1] || ''}" --IGNORE-CACHE="${args[2] ? 'true' : 'false'}"`, { stdio });
execSync(`node dish/index.js ${DECOMPILE_VERSION}${args[1] ? ' ' + args[1] : ''}`, { stdio });
} catch (e) {
error(e);
return process.exit(1);
}
}, 1000 * 5);
return;
warn(`Workspace for version '${DECOMPILE_VERSION.split('/')[1]}' wasn't found. Running init.js`);
await generateWorkspace();
}

if (!fs.existsSync(`dish/libraries/${DECOMPILE_VERSION.split('/')[1]}.json`)) {
error(`Could not find file: dish/libraries/${DECOMPILE_VERSION.split('/')[1]}.json`);
return process.exit(1);
}

if (!fs.existsSync(`cache/${DECOMPILE_VERSION.split('/')[1]}/META-INF/libraries.list`)) {
error(`Could not find file: cache/${DECOMPILE_VERSION.split('/')[1]}/META-INF/libraries.list`);
return process.exit(1);
}

if (fs.existsSync('dish/workspace')) {
console.time('Moved directories');
warn('Dish workspace already exists. Moving it, this may take a while...');
Expand Down Expand Up @@ -88,4 +86,51 @@ function parseLibraries(libraries) {
execSync('cd dish/workspace && git add .', { stdio });
execSync('cd dish/workspace && git commit -m "applied patches"', { stdio });
process.exit(0);
})();
})();

async function generateWorkspace() {
return new Promise(async (res, rej) => {
await init(DECOMPILE_VERSION, args[1] || null);
execSync(`node dish/index.js ${DECOMPILE_VERSION}${args[1] ? ' ' + args[1] : ''}`, { stdio });
res();
});
}

async function cacheServer(version = DECOMPILE_VERSION.split('/')[1]) {
const manifestReq = await fetch('https://launchermeta.mojang.com/mc/game/version_manifest_v2.json');
if (manifestReq.status !== 200) {
error('https://launchermeta.mojang.com/mc/game/version_manifest_v2.json returned ' + manifestReq.status);
return process.exit(1);
}

const manifest = await manifestReq.json();
const versionJson = manifest.versions.filter(v => v.id === version)[0];
if (!versionJson) {
error(`Could not find version '${version}'`);
return process.exit(1);
}

const packageReq = await fetch(versionJson.url);
if (manifestReq.status !== 200) {
error(versionJson.url + ' returned ' + packageReq.status);
return process.exit(1);
}

const package = await packageReq.json();
await fs.promises.mkdir(`cache/${version}`, { recursive: true });
await fs.promises.writeFile(`cache/${version}/${version}.json`, JSON.stringify(package));

log('Downloading server jar...');
const file = fs.createWriteStream(`cache/${version}/server.jar`);
await downloadServerJar(package.downloads.server.url, file);
log('Server jar finished downloading');
execSync(`cd cache/${version} && jar xf server.jar META-INF`, { stdio });
}

async function downloadServerJar(url, file) {
return new Promise((res, rej) => {
const request = https.get(url, (res) => res.pipe(file));
request.on('error', (e) => rej(e));
request.on('close', () => res());
});
}
10 changes: 5 additions & 5 deletions dish/libraries/1.20.6.json → dish/libraries/1.21.8.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": "1.20.6",
"api_version": "R0.1-SNAPSHOT",
"version": "1.21.8",
"api_version": "R0.2-SNAPSHOT",
"libraries": [
{
"downloads": {
Expand All @@ -11,10 +11,10 @@
},
{
"downloads": {
"url": "https://maven.ouja.net/net/ouja/api/1.20.6-R0.1-SNAPSHOT/api-1.20.6-R0.1-20240523.231723-1.jar",
"path": "net/ouja/api/1.20.6/1.20.6-R0.1-SNAPSHOT.jar"
"url": "https://maven.ouja.net/net/ouja/api/1.21.8-R0.2-SNAPSHOT/api-1.21.8-R0.2-20250924.021552-2.jar",
"path": "net/ouja/api/1.21.8/1.21.8-R0.2-SNAPSHOT.jar"
},
"name": "net.ouja:api:1.20.6-R0.1-SNAPSHOT"
"name": "net.ouja:api:1.21.8-R0.2-SNAPSHOT"
}
]
}
20 changes: 20 additions & 0 deletions dish/libraries/1.21.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": "1.21",
"api_version": "R0.2-SNAPSHOT",
"libraries": [
{
"downloads": {
"url": "https://repo1.maven.org/maven2/org/yaml/snakeyaml/2.0/snakeyaml-2.0.jar",
"path": "org/yaml/snakeyaml/2.0/snakeyaml-2.0.jar"
},
"name": "org.yaml:snakeyaml:2.0"
},
{
"downloads": {
"url": "https://maven.ouja.net/net/ouja/api/1.21-R0.2-SNAPSHOT/api-1.21-R0.2-20240707.232548-2.jar",
"path": "net/ouja/api/1.21/1.21-R0.2-SNAPSHOT.jar"
},
"name": "net.ouja:api:1.21-R0.2-SNAPSHOT"
}
]
}
4 changes: 2 additions & 2 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ What you will need to contribute:

Now that you have the required stuff installed, what you will need to do is clone Dish and run the following command `npm install`. Once the npm packages are installed, run the command `git submodule update --init --recursive`.

Once everything is ready, run the command `node init.js`. Then, hopefully, no patches get rejected, then you can run the command `node dish`. After everything is set up, you can go to the directory `~/dish/workspace` and modify the Minecraft or Dish code.
Once everything is ready, run the command `node dish`. After everything is set up, you can go to the directory `~/dish/workspace` and modify the Minecraft or Dish code.

### Patches

Expand All @@ -26,7 +26,7 @@ When you are finished making the changes, run the command in the home directory

#### Updating to a new version

If you wish to update Dish to a new version that has been recently released, run the command `node dish/index.js <new_build_type>/<new_version> <old_build_type>/<old_version> <(true | false) -- If true, it will ignore the cache>`. This will very likely cause an error, which means you will need to fix the rejected patches or new files that have new decompile errors. This can be done by going to the workspaces directory and the new version's sub directory. Opening it in the IDE of your choice, then, fix the errors and run `node patches/generatePatches <build_type>/<version>`.
If you wish to update Dish to a new version that has been recently released, run the command `node dish <new_build_type>/<new_version> <old_build_type>/<old_version> <(true | false) -- If true, it will ignore the cache>`. This will very likely cause an error, which means you will need to fix the rejected patches or new files that have new decompile errors. This can be done by going to the workspaces directory and the new version's sub directory. Opening it in the IDE of your choice, then, fix the errors and run `node patches/generatePatches <build_type>/<version>`.

##### Publishing

Expand Down
42 changes: 0 additions & 42 deletions init.js

This file was deleted.

10 changes: 9 additions & 1 deletion libs/static/build.gradle.dish.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
plugins {
id 'java'
id 'org.ajoberstar.grgit' version '4.1.0'
id 'org.ajoberstar.grgit' version '5.3.3'
}

group 'net.minecraft'
version '{VERSION}'

java {
withJavadocJar()
withSourcesJar()
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}

ext {
api_version = version + '-{API_VERSION}'
}
Expand Down
2 changes: 1 addition & 1 deletion mache
Submodule mache updated 109 files
13 changes: 13 additions & 0 deletions patches/release/1.21.8/net/minecraft/ChatFormatting.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/src/main/java/net/minecraft/ChatFormatting.java b/src/main/java/net/minecraft/ChatFormatting.java
index 12c6b47..2077793 100644
--- a/src/main/java/net/minecraft/ChatFormatting.java
+++ b/src/main/java/net/minecraft/ChatFormatting.java
@@ -38,7 +38,7 @@ public enum ChatFormatting implements StringRepresentable {
RESET("RESET", 'r', -1, null);

public static final Codec<ChatFormatting> CODEC = StringRepresentable.fromEnum(ChatFormatting::values);
- public static final char PREFIX_CODE = '§';
+ public static final char PREFIX_CODE = '\u00a7'; // decompiler error
private static final Map<String, ChatFormatting> FORMATTING_BY_NAME = Arrays.stream(values())
.collect(Collectors.toMap(formatting -> cleanName(formatting.name), chatFormatter -> (ChatFormatting)chatFormatter));
private static final Pattern STRIP_FORMATTING_PATTERN = Pattern.compile("(?i)§[0-9A-FK-OR]");
12 changes: 12 additions & 0 deletions patches/release/1.21.8/net/minecraft/CrashReport.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/src/main/java/net/minecraft/CrashReport.java b/src/main/java/net/minecraft/CrashReport.java
index b5180b2..647b8ce 100644
--- a/src/main/java/net/minecraft/CrashReport.java
+++ b/src/main/java/net/minecraft/CrashReport.java
@@ -34,6 +34,7 @@ public class CrashReport {
public CrashReport(String title, Throwable exception) {
this.title = title;
this.exception = exception;
+ this.systemReport.setDetail("DishServer", new net.ouja.dish.DishCrashReport());
}

public String getTitle() {
Loading
Loading