Skip to content

Commit

Permalink
No more syncing and now properly trigger clinit on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
Dev0Louis committed Sep 15, 2024
1 parent 721447d commit 79f5072
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
6 changes: 6 additions & 0 deletions src/main/java/dev/enjarai/trickster/Trickster.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

public record SpellExecutorType<T extends SpellExecutor>(StructEndec<T> endec) {
public static final RegistryKey<Registry<SpellExecutorType<?>>> REGISTRY_KEY = RegistryKey.ofRegistry(Trickster.id("spell_executor_type"));
public static final Registry<SpellExecutorType<?>> REGISTRY = FabricRegistryBuilder.createSimple(REGISTRY_KEY).attribute(RegistryAttribute.SYNCED).buildAndRegister();
public static final Registry<SpellExecutorType<?>> REGISTRY = FabricRegistryBuilder.createSimple(REGISTRY_KEY).buildAndRegister();

public static final SpellExecutorType<DefaultSpellExecutor> DEFAULT = register("default", DefaultSpellExecutor.ENDEC);
public static final SpellExecutorType<FoldingSpellExecutor> FOLDING = register("folding", FoldingSpellExecutor.ENDEC);
Expand All @@ -22,4 +22,8 @@ public record SpellExecutorType<T extends SpellExecutor>(StructEndec<T> endec) {
private static <T extends SpellExecutor> SpellExecutorType<T> register(String name, StructEndec<T> codec) {
return Registry.register(REGISTRY, Trickster.id(name), new SpellExecutorType<>(codec));
}

public static void register() {
// init the class :brombeere:
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public RegistryEntry.Reference<FragmentType<?>> add(RegistryKey<FragmentType<?>>
INT_ID_LOOKUP.put(hash, key.getValue());
return super.add(key, value, info);
}
}).attribute(RegistryAttribute.SYNCED).buildAndRegister();;
}).buildAndRegister();

public static final FragmentType<TypeFragment> TYPE = register("type", TypeFragment.ENDEC, 0x66cc00);
public static final FragmentType<NumberFragment> NUMBER = register("number", NumberFragment.ENDEC, 0xddaa00);
Expand All @@ -66,6 +66,10 @@ private static <T extends Fragment> FragmentType<T> 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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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<T extends ManaPool>(StructEndec<T> endec) {
public static final RegistryKey<Registry<ManaPoolType<?>>> REGISTRY_KEY = RegistryKey.ofRegistry(Trickster.id("mana_pool_type"));
public static final Registry<ManaPoolType<?>> REGISTRY = FabricRegistryBuilder.createSimple(REGISTRY_KEY).attribute(RegistryAttribute.SYNCED).buildAndRegister();
public static final Registry<ManaPoolType<?>> REGISTRY = FabricRegistryBuilder.createSimple(REGISTRY_KEY).buildAndRegister();

public static final ManaPoolType<SimpleManaPool> SIMPLE = register("simple", SimpleManaPool.ENDEC);

private static <T extends ManaPool> ManaPoolType<T> register(String name, StructEndec<T> endec) {
return Registry.register(REGISTRY, Trickster.id(name), new ManaPoolType<>(endec));
}

public static void register() {
// init the class :brombeere:
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public RegistryEntry.Reference<Trick> add(RegistryKey<Trick> 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());
Expand Down

0 comments on commit 79f5072

Please sign in to comment.