diff --git a/common/src/common/java/info/u_team/useful_dragon_eggs/init/UsefulDragonEggsGameRules.java b/common/src/common/java/info/u_team/useful_dragon_eggs/init/UsefulDragonEggsGameRules.java index 497fae8..bc96725 100644 --- a/common/src/common/java/info/u_team/useful_dragon_eggs/init/UsefulDragonEggsGameRules.java +++ b/common/src/common/java/info/u_team/useful_dragon_eggs/init/UsefulDragonEggsGameRules.java @@ -1,54 +1,20 @@ package info.u_team.useful_dragon_eggs.init; -import com.google.common.base.Supplier; -import com.google.common.base.Suppliers; - -import info.u_team.u_team_core.api.event.CommonEvents; +import info.u_team.u_team_core.api.registry.GameRuleRegister; import info.u_team.u_team_core.api.registry.LazyEntry; import info.u_team.useful_dragon_eggs.UsefulDragonEggsReference; -import net.minecraft.core.registries.Registries; import net.minecraft.world.level.GameRules; import net.minecraft.world.level.GameRules.BooleanValue; -import net.minecraft.world.level.GameRules.Key; public class UsefulDragonEggsGameRules { - public static final LazyEntry> RULE_DO_BREAK_BEDROCK = new LazyEntry>() { // TODO rework - - private Supplier> value = Suppliers.memoize(() -> GameRules.register(UsefulDragonEggsReference.MODID + ":doBreakBedrock", GameRules.Category.MISC, GameRules.BooleanValue.create(true))); - - @Override - public Key get() { - return value.get(); - } - - @Override - public boolean isPresent() { - return true; - } - }; + public static final GameRuleRegister GAME_RULES = GameRuleRegister.create(); + + public static final LazyEntry> RULE_DO_BREAK_BEDROCK = GAME_RULES.register(UsefulDragonEggsReference.MODID, "doBreakBedrock", GameRules.Category.MISC, () -> GameRules.BooleanValue.create(true)); - public static final LazyEntry> RULE_DO_RESPAWN_DRAGON_EGG = new LazyEntry>() { // TODO rework - - private Supplier> value = Suppliers.memoize(() -> GameRules.register(UsefulDragonEggsReference.MODID + ":doRespawnDragonEgg", GameRules.Category.MISC, GameRules.BooleanValue.create(true))); - - @Override - public Key get() { - return value.get(); - } - - @Override - public boolean isPresent() { - return true; - } - }; + public static final LazyEntry> RULE_DO_RESPAWN_DRAGON_EGG = GAME_RULES.register(UsefulDragonEggsReference.MODID, "doRespawnDragonEgg", GameRules.Category.MISC, () -> GameRules.BooleanValue.create(true)); static void register() { - CommonEvents.registerRegister(key -> { - if (key == Registries.BLOCK) { - RULE_DO_BREAK_BEDROCK.get(); // Register for now this way. TODO rework - RULE_DO_RESPAWN_DRAGON_EGG.get(); - } - }); + GAME_RULES.register(); } }