Skip to content

Commit

Permalink
fix: Registries are now automatically registered.
Browse files Browse the repository at this point in the history
  • Loading branch information
sylv256 committed Nov 24, 2024
1 parent 03ca0d9 commit 56a9d01
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 1 deletion.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@
- Mod icon.

## Changed
- Clarified multiloader support in documentation.
- Clarified multiloader support in documentation.

## Fixed
- Registries are now automatically registered.
2 changes: 2 additions & 0 deletions common/src/main/java/house/greenhouse/silicate/Silicate.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package house.greenhouse.silicate;

import house.greenhouse.silicate.api.SilicateRegistries;
import house.greenhouse.silicate.platform.SilicatePlatformHelper;
import house.greenhouse.silicate.test.SilicateGameTests;
import net.minecraft.resources.ResourceLocation;
Expand All @@ -22,6 +23,7 @@ public class Silicate {

public static void init() {
LOG.info("Initializing Silicate");
SilicateRegistries.registerAll();
}

public static SilicatePlatformHelper getHelper() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

import com.mojang.serialization.Lifecycle;
import house.greenhouse.silicate.api.condition.GameConditionType;
import house.greenhouse.silicate.api.condition.GameConditionTypes;
import house.greenhouse.silicate.api.context.param.ContextParamType;
import house.greenhouse.silicate.api.context.param.ContextParamTypes;
import net.minecraft.core.MappedRegistry;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceKey;
import org.jetbrains.annotations.ApiStatus;

import static house.greenhouse.silicate.Silicate.id;

Expand All @@ -17,6 +20,12 @@ public final class SilicateRegistries {
public static final Registry<ContextParamType<?>> CONTEXT_PARAM_TYPE = create("context_param_type");

private SilicateRegistries() {}

@ApiStatus.Internal
public static void registerAll() {
GameConditionTypes.registerAll();
ContextParamTypes.registerAll();
}

private static <T> Registry<T> create(String name) {
return new MappedRegistry<>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import house.greenhouse.silicate.api.SilicateRegistries;
import house.greenhouse.silicate.api.condition.builtin.*;
import net.minecraft.core.Registry;
import org.jetbrains.annotations.ApiStatus;

import static house.greenhouse.silicate.Silicate.id;

Expand All @@ -24,6 +25,9 @@ public final class GameConditionTypes {
public static final GameConditionType<PlayerGameTypeCondition> PLAYER_GAME_TYPE = register("player_game_type", PlayerGameTypeCondition.CODEC);

private GameConditionTypes() {}

@ApiStatus.Internal
public static void registerAll() {}

private static <T extends GameCondition<T>> GameConditionType<T> register(
String name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.ApiStatus;

import static house.greenhouse.silicate.Silicate.id;

Expand Down Expand Up @@ -40,6 +41,9 @@ public final class ContextParamTypes {
public static final ContextParamType<Unit> UNIT = new ContextParamType<>(id("unit"), Unit.class);

private ContextParamTypes() {}

@ApiStatus.Internal
public static void registerAll() {}

private static <T> ContextParamType<T> register(String name, Class<T> clazz) {
return Registry.register(
Expand Down

0 comments on commit 56a9d01

Please sign in to comment.