Skip to content

Commit

Permalink
Use uteamcore implementation of gamerules
Browse files Browse the repository at this point in the history
  • Loading branch information
HyCraftHD committed Sep 9, 2023
1 parent 11dbe6b commit aa0a90d
Showing 1 changed file with 6 additions and 40 deletions.
Original file line number Diff line number Diff line change
@@ -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<GameRules.Key<BooleanValue>> RULE_DO_BREAK_BEDROCK = new LazyEntry<GameRules.Key<BooleanValue>>() { // TODO rework

private Supplier<GameRules.Key<BooleanValue>> value = Suppliers.memoize(() -> GameRules.register(UsefulDragonEggsReference.MODID + ":doBreakBedrock", GameRules.Category.MISC, GameRules.BooleanValue.create(true)));

@Override
public Key<BooleanValue> get() {
return value.get();
}

@Override
public boolean isPresent() {
return true;
}
};
public static final GameRuleRegister GAME_RULES = GameRuleRegister.create();

public static final LazyEntry<GameRules.Key<BooleanValue>> RULE_DO_BREAK_BEDROCK = GAME_RULES.register(UsefulDragonEggsReference.MODID, "doBreakBedrock", GameRules.Category.MISC, () -> GameRules.BooleanValue.create(true));

public static final LazyEntry<GameRules.Key<BooleanValue>> RULE_DO_RESPAWN_DRAGON_EGG = new LazyEntry<GameRules.Key<BooleanValue>>() { // TODO rework

private Supplier<GameRules.Key<BooleanValue>> value = Suppliers.memoize(() -> GameRules.register(UsefulDragonEggsReference.MODID + ":doRespawnDragonEgg", GameRules.Category.MISC, GameRules.BooleanValue.create(true)));

@Override
public Key<BooleanValue> get() {
return value.get();
}

@Override
public boolean isPresent() {
return true;
}
};
public static final LazyEntry<GameRules.Key<BooleanValue>> 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();
}
}

0 comments on commit aa0a90d

Please sign in to comment.