From 79f50725db18f322d9aa524a41c096b70bd50b60 Mon Sep 17 00:00:00 2001 From: D1p4k <82884007+D1p4k@users.noreply.github.com> Date: Sun, 15 Sep 2024 17:06:43 +0200 Subject: [PATCH] No more syncing and now properly trigger clinit on startup --- src/main/java/dev/enjarai/trickster/Trickster.java | 6 ++++++ .../spell/execution/executor/SpellExecutorType.java | 6 +++++- .../enjarai/trickster/spell/fragment/FragmentType.java | 6 +++++- .../dev/enjarai/trickster/spell/mana/ManaPoolType.java | 9 +++++---- .../java/dev/enjarai/trickster/spell/trick/Tricks.java | 2 +- 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/main/java/dev/enjarai/trickster/Trickster.java b/src/main/java/dev/enjarai/trickster/Trickster.java index 1411b189..64d79cb2 100644 --- a/src/main/java/dev/enjarai/trickster/Trickster.java +++ b/src/main/java/dev/enjarai/trickster/Trickster.java @@ -14,7 +14,10 @@ import dev.enjarai.trickster.particle.ModParticles; import dev.enjarai.trickster.screen.ModScreenHandlers; import dev.enjarai.trickster.spell.ItemTriggerHelper; +import dev.enjarai.trickster.spell.execution.executor.SpellExecutorType; +import dev.enjarai.trickster.spell.fragment.FragmentType; import dev.enjarai.trickster.spell.fragment.VectorFragment; +import dev.enjarai.trickster.spell.mana.ManaPoolType; import dev.enjarai.trickster.spell.trick.Tricks; import net.fabricmc.api.ModInitializer; @@ -60,6 +63,9 @@ public void onInitialize() { ModDamageTypes.register(); Tricks.register(); ModCriteria.register(); + FragmentType.register(); + ManaPoolType.register(); + SpellExecutorType.register(); PlayerBlockBreakEvents.BEFORE.register((world, player, pos, state, blockEntity) -> { if (player instanceof ServerPlayerEntity serverPlayer) diff --git a/src/main/java/dev/enjarai/trickster/spell/execution/executor/SpellExecutorType.java b/src/main/java/dev/enjarai/trickster/spell/execution/executor/SpellExecutorType.java index f01fcd2d..9a1cdd56 100644 --- a/src/main/java/dev/enjarai/trickster/spell/execution/executor/SpellExecutorType.java +++ b/src/main/java/dev/enjarai/trickster/spell/execution/executor/SpellExecutorType.java @@ -12,7 +12,7 @@ public record SpellExecutorType(StructEndec endec) { public static final RegistryKey>> REGISTRY_KEY = RegistryKey.ofRegistry(Trickster.id("spell_executor_type")); - public static final Registry> REGISTRY = FabricRegistryBuilder.createSimple(REGISTRY_KEY).attribute(RegistryAttribute.SYNCED).buildAndRegister(); + public static final Registry> REGISTRY = FabricRegistryBuilder.createSimple(REGISTRY_KEY).buildAndRegister(); public static final SpellExecutorType DEFAULT = register("default", DefaultSpellExecutor.ENDEC); public static final SpellExecutorType FOLDING = register("folding", FoldingSpellExecutor.ENDEC); @@ -22,4 +22,8 @@ public record SpellExecutorType(StructEndec endec) { private static SpellExecutorType register(String name, StructEndec codec) { return Registry.register(REGISTRY, Trickster.id(name), new SpellExecutorType<>(codec)); } + + public static void register() { + // init the class :brombeere: + } } diff --git a/src/main/java/dev/enjarai/trickster/spell/fragment/FragmentType.java b/src/main/java/dev/enjarai/trickster/spell/fragment/FragmentType.java index 0457603f..8b786cc1 100644 --- a/src/main/java/dev/enjarai/trickster/spell/fragment/FragmentType.java +++ b/src/main/java/dev/enjarai/trickster/spell/fragment/FragmentType.java @@ -39,7 +39,7 @@ public RegistryEntry.Reference> add(RegistryKey> INT_ID_LOOKUP.put(hash, key.getValue()); return super.add(key, value, info); } - }).attribute(RegistryAttribute.SYNCED).buildAndRegister();; + }).buildAndRegister(); public static final FragmentType TYPE = register("type", TypeFragment.ENDEC, 0x66cc00); public static final FragmentType NUMBER = register("number", NumberFragment.ENDEC, 0xddaa00); @@ -66,6 +66,10 @@ private static FragmentType register(String name, Struct return Registry.register(REGISTRY, Trickster.id(name), new FragmentType<>(codec, OptionalInt.empty())); } + public static void register() { + // init the class :brombeere: + } + public MutableText getName() { var id = REGISTRY.getId(this); if (id == null) { diff --git a/src/main/java/dev/enjarai/trickster/spell/mana/ManaPoolType.java b/src/main/java/dev/enjarai/trickster/spell/mana/ManaPoolType.java index f9747261..99081c4a 100644 --- a/src/main/java/dev/enjarai/trickster/spell/mana/ManaPoolType.java +++ b/src/main/java/dev/enjarai/trickster/spell/mana/ManaPoolType.java @@ -1,21 +1,22 @@ package dev.enjarai.trickster.spell.mana; -import com.mojang.serialization.Lifecycle; import dev.enjarai.trickster.Trickster; import io.wispforest.endec.StructEndec; import net.fabricmc.fabric.api.event.registry.FabricRegistryBuilder; -import net.fabricmc.fabric.api.event.registry.RegistryAttribute; import net.minecraft.registry.Registry; import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.SimpleRegistry; public record ManaPoolType(StructEndec endec) { public static final RegistryKey>> REGISTRY_KEY = RegistryKey.ofRegistry(Trickster.id("mana_pool_type")); - public static final Registry> REGISTRY = FabricRegistryBuilder.createSimple(REGISTRY_KEY).attribute(RegistryAttribute.SYNCED).buildAndRegister(); + public static final Registry> REGISTRY = FabricRegistryBuilder.createSimple(REGISTRY_KEY).buildAndRegister(); public static final ManaPoolType SIMPLE = register("simple", SimpleManaPool.ENDEC); private static ManaPoolType register(String name, StructEndec endec) { return Registry.register(REGISTRY, Trickster.id(name), new ManaPoolType<>(endec)); } + + public static void register() { + // init the class :brombeere: + } } diff --git a/src/main/java/dev/enjarai/trickster/spell/trick/Tricks.java b/src/main/java/dev/enjarai/trickster/spell/trick/Tricks.java index 2302a7d0..a5073ef1 100644 --- a/src/main/java/dev/enjarai/trickster/spell/trick/Tricks.java +++ b/src/main/java/dev/enjarai/trickster/spell/trick/Tricks.java @@ -55,7 +55,7 @@ public RegistryEntry.Reference add(RegistryKey key, Trick value, R LOOKUP.put(value.getPattern(), value); return super.add(key, value, info); } - }).attribute(RegistryAttribute.SYNCED).buildAndRegister(); + }).buildAndRegister(); // Functions public static final ExecuteTrick EXECUTE = register("execute", new ExecuteTrick());