Skip to content

Instantly share code, notes, and snippets.

View zlataovce's full-sized avatar

Matouš Kučera zlataovce

View GitHub Profile
@zlataovce
zlataovce / main.js
Created November 7, 2025 16:36
A slicer script for importing Minecraft JARs easily.
const MANIFEST_URL = "https://piston-meta.mojang.com/mc/game/version_manifest_v2.json";
const categorizeVersion = (version) => {
const v = version.id;
if (v.startsWith("c") || v.startsWith("rd-")) return "classic";
if (v.startsWith("inf-") || v.startsWith("in-")) return "infdev_indev";
if (v.startsWith("a")) return "alpha";
if (v.startsWith("b")) return "beta";
if (/^\d{2}w\d{2}[a-z]/.test(v) || /^\d{4}/.test(v)) return "snapshots";
@zlataovce
zlataovce / buffer_stream.ts
Last active October 29, 2024 16:11
A streaming DataView abstraction.
// A streaming DataView abstraction. (c) 2024 zlataovce (github.com/zlataovce)
// License: Public domain (or MIT if needed). Attribution appreciated.
// https://gist.github.com/zlataovce/7db8bc7cfe8b7897816495bf2ec3858d
const DEFAULT_LITTLE_ENDIAN = true;
const MIN_READ = 1024; // 1 KiB
const INITIAL_BUF_SIZE = MIN_READ * 1.5; // 1.5 KiB
type Awaitable<T> = T | PromiseLike<T>;
export const EOF = new Error("End of stream");
@zlataovce
zlataovce / buffer.ts
Created September 30, 2024 20:50
An offset-tracking DataView abstraction.
// An offset-tracking DataView abstraction. (c) 2024 zlataovce (github.com/zlataovce)
// License: Public domain (or MIT if needed). Attribution appreciated.
// https://gist.github.com/zlataovce/42b87282e33bef4295981e177754dc13
const DEFAULT_BUFFER_SIZE = 1024;
const DEFAULT_RESIZE = 32;
const DEFAULT_LITTLE_ENDIAN = true;
export interface Buffer {
view: DataView;
arrayView: Uint8Array;
@zlataovce
zlataovce / ClassNode.java
Created June 18, 2024 16:18
A Java class file header reader.
package dev.cephx.cfr.reader;
import java.util.Objects;
public final class ClassNode {
private int major;
private int minor;
private int access;
private String name;
@zlataovce
zlataovce / mappings.py
Last active August 25, 2023 05:30
A mapping joiner for creating Mojang -> Spigot ProGuard mappings, useful for deobfuscation of heapdumps.
from argparse import ArgumentParser
from re import compile
CLASS_PATTERN = compile(r" -> ([^:]+):$")
# you can get these mapping files at Spigot's developer hub and Mojang's version metadata
# and you can get the links to them from https://mappings.cephx.dev/1.20.1/licenses.html
if __name__ == "__main__":
parser = ArgumentParser(description="Joins Mojang ProGuard and Spigot CSRG class mappings.")
parser.add_argument("--mojang", "-m", help="the Mojang mapping path", default="./server.txt")