Skip to content

Instantly share code, notes, and snippets.

View alcatrazEscapee's full-sized avatar
💭
This party never stops, time is dead and meaning has no meaning!

alcatrazEscapee

💭
This party never stops, time is dead and meaning has no meaning!
View GitHub Profile

JSON Mixin Specification

Overview

This is intended to be a specification for allowing multiple JSON files to be merged at parse time into a single file. It's intended application is in Minecraft modding, for allowing multiple mods to make modifications to the same JSON file without causing conflicts. This has been a problem mainly caused by block loot tables (and was eventually solved by global loot tables), but with the introduction of all of world generation in 1.16.2 snapshots, this method may not prove useful in the long run.

The goal is to make a data driven JSON merging system, which satisfies the needs of mods to inject, replace, or modify existing JSONs. In Minecraft, this could be accomplished by a top level tag, e.g. "__apply__": "mixin" to designate a specific JSON as a mixin and load it appropriately. Additionally, it could be possible to have another tag (global_mixin) which causes it to apply to every possible file of the same type (much as in the way that global loot functions work

@alcatrazEscapee
alcatrazEscapee / BiomeIdOrderTest.java
Created October 27, 2020 23:00
A test mod for biome ID ordering issues in Minecraft Forge 1.16.3
package net.minecraftforge.debug.world;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.BiomeMaker;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
@alcatrazEscapee
alcatrazEscapee / AoC2020Day18P2Badly.py
Created December 18, 2020 06:49
The worst way to solve day 18
def main_badly(text: str):
lines = text.split('\n')
total = 0
class Int:
def __init__(self, i: int):
self.i = i
def __add__(self, other):
return Int(self.i * other.i)
def __mul__(self, other):
return Int(self.i + other.i)
@Override
public void apply(Random random, IChunk chunkIn, Biome biomeIn, int x, int z, int startHeight, double surfaceNoise, BlockState defaultBlock, BlockState defaultFluid, int seaLevel, long seed, SurfaceBuilderConfig config)
{
double squareIcebergValue = 0.0D;
double underwaterIcebergValue = 0.0D;
BlockPos.Mutable mutablePos = new BlockPos.Mutable();
float seaLevelTemperature = biomeIn.getTemperature(mutablePos.set(x, 63, z));
double icebergValue = Math.min(Math.abs(surfaceNoise), icebergNoise.getValue(x * 0.1D, z * 0.1D, false) * 15.0D);
if (icebergValue > 1.8D)
{
@alcatrazEscapee
alcatrazEscapee / IntArrayBuilder.java
Created January 3, 2021 00:21
To avoid writing the same switch based anon. class every single time.
package net.dries007.tfc.util;
import java.util.ArrayList;
import java.util.List;
import java.util.function.IntConsumer;
import java.util.function.IntSupplier;
import net.minecraft.util.IIntArray;
import net.minecraft.util.IntReferenceHolder;
@alcatrazEscapee
alcatrazEscapee / ForgeConfigExplainer.md
Created February 11, 2021 17:17
What the heck is up with configs in Forge >1.12 (for users)?

What the heck is up with configs in Forge >1.12?

In Forge versions > 1.12, there are multiple types of config files. Each of these have a specific purpose. So whenever you're looking for a config option, first make sure you're looking in the right file! So, what are the types?

  1. Server Configs
  • these are unique per world.
  • located in the world folder, e.g. .minecraft/saves/<world>/serverconfig/modid-server.toml
  • automatically synchronized from server -> client
  • can be overriden (i.e. for the purpose of not having to edit the config every time you create a world) by the defaultconfigs folder - any server configs found under .minecraft/defaultconfigs will be copied to any new worlds when created (overriding the mod defaults)
@alcatrazEscapee
alcatrazEscapee / Why Are Rivers So Complicated.md
Last active January 30, 2025 18:41
Why Are Rivers So Complicated?

Update

You can now read this document / article, at https://alcatrazescapee.com/rivers/. It will be updated further there. The original content is still here, below


Why Are Rivers So Complicated?

Let's narrow that down a bit. This document will try to explain some of the difficulties, limitations, and possible ways to generate rivers in Minecraft. There have been many papers, articles, and other medium which have generated realistic rivers to great success. So what makes Minecraft so much more difficult, or what makes these other methodologies so difficult? And what methods have found success?

@alcatrazEscapee
alcatrazEscapee / NoiseCodecs.java
Created April 6, 2021 11:24
An example of a `Codec` structure for `INoise2D` from the TerraFirmaCraft 1.16 Mod
package net.dries007.tfc.world.noise;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.util.ResourceLocation;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
public class NoiseCodecs
/*
* This code is licensed under CC0 1.0. Use it, do whatever you want with it!
*/
import java.util.List;
import java.util.function.Predicate;
public class PerfectMatchingWithEdmondsMatrix
{
/**
@alcatrazEscapee
alcatrazEscapee / gradients.py
Created May 20, 2021 02:17
A script to create a smooth 2D gradient between a series of fixed points
# Requires the pillow module
from argparse import ArgumentParser
from PIL import Image
from typing import NamedTuple, Tuple, List
Point = NamedTuple('Point', x=int, y=int, r=int, g=int, b=int)
def main():