NucleoidMC / plasmid

Server-side minigame development library based on Fabric.
GNU Lesser General Public License v3.0
88 stars 31 forks source link

Dynamic config registry #268

Closed Gegy closed 1 year ago

Gegy commented 1 year ago

Draft for now, to be integrated with a future breaking release.

Hugman76 commented 1 year ago

We can now use Fabric API 0.86.1+ for registering dynamic registries:

import net.fabricmc.fabric.api.event.registry.DynamicRegistries;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey;

public class MyRegistryKeys {
    public static final RegistryKey<Registry<Bar>> BAR = RegistryKey.ofRegistry(new Identifier("foo", "bar"));

    public static void register() {
        DynamicRegistries.register(BAR, Bar.CODEC);
    }
}
Hugman76 commented 1 year ago

This PR can now target staging/0.6 and be merged maybe?

Hugman76 commented 1 year ago

Why are game portals still managed by their own class rather than a dynamic registry?

Gegy commented 1 year ago

No specific reason here - definitely something that can and should be done, just needs a bit more work than configs 🙂

Hugman76 commented 1 year ago

Okay then let's leave that to another PR I think But we might want to get it in 0.6 too

Hugman76 commented 1 year ago

Also as a side note: using FAPI dynamic resistry will have to make us move all data/games folders to data/plasmid/games