-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use uteamcore implementation of gamerules
- Loading branch information
Showing
1 changed file
with
6 additions
and
40 deletions.
There are no files selected for viewing
46 changes: 6 additions & 40 deletions
46
common/src/common/java/info/u_team/useful_dragon_eggs/init/UsefulDragonEggsGameRules.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |