Package net.minecraft.world
Class GameRules
java.lang.Object
net.minecraft.world.GameRules
public class GameRules extends Object
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static interfaceGameRules.Acceptor<T extends GameRules.Rule<T>>static classGameRules.BooleanRulestatic classGameRules.Categorystatic classGameRules.IntRulestatic classGameRules.Key<T extends GameRules.Rule<T>>static classGameRules.Rule<T extends GameRules.Rule<T>>static classGameRules.Type<T extends GameRules.Rule<T>>static interfaceGameRules.VisitorA visitor used to visit all game rules. -
Field Summary
-
Constructor Summary
Constructors Modifier Constructor Description GameRules()GameRules(com.mojang.serialization.DynamicLike<?> dynamicLike)privateGameRules(Map<GameRules.Key<?>,GameRules.Rule<?>> rules) -
Method Summary
Modifier and Type Method Description static voidaccept(GameRules.Visitor visitor)Make the visitor visit all registered game rules.private static <T extends GameRules.Rule<T>>
voidaccept(GameRules.Visitor consumer, GameRules.Key<?> key, GameRules.Type<?> type)GameRulescopy()<T extends GameRules.Rule<T>>
Tget(GameRules.Key<T> key)booleangetBoolean(GameRules.Key<GameRules.BooleanRule> rule)intgetInt(GameRules.Key<GameRules.IntRule> rule)private voidload(com.mojang.serialization.DynamicLike<?> dynamicLike)private static <T extends GameRules.Rule<T>>
GameRules.Key<T>register(String name, GameRules.Category category, GameRules.Type<T> type)voidsetAllValues(GameRules rules, MinecraftServer server)private <T extends GameRules.Rule<T>>
voidsetValue(GameRules.Key<T> key, GameRules rules, MinecraftServer server)CompoundTagtoNbt()
-
Field Details
-
LOGGER
-
RULE_TYPES
-
DO_FIRE_TICK
-
DO_MOB_GRIEFING
A game rule which regulates whether mobs can modify the world.Generally one is expected to test this rule before an entity modifies the world.
In vanilla, this includes:
- Whether creeper explosions destroy blocks
- Whether a zombie can break down a door
- Whether a wither killing an entity will place or drop a wither rose
-
KEEP_INVENTORY
A game rule which regulates whether player inventories should be persist through respawning. -
DO_MOB_SPAWNING
A game rule which regulates whether mobs can spawn naturally. -
DO_MOB_LOOT
A game rule which regulates whether mobs should drop loot on death. -
DO_TILE_DROPS
A game rule which regulates whether blocks should drop their items when broken. -
DO_ENTITY_DROPS
-
COMMAND_BLOCK_OUTPUT
-
NATURAL_REGENERATION
-
DO_DAYLIGHT_CYCLE
-
LOG_ADMIN_COMMANDS
-
SHOW_DEATH_MESSAGES
-
RANDOM_TICK_SPEED
-
SEND_COMMAND_FEEDBACK
-
REDUCED_DEBUG_INFO
-
SPECTATORS_GENERATE_CHUNKS
-
SPAWN_RADIUS
-
DISABLE_ELYTRA_MOVEMENT_CHECK
-
MAX_ENTITY_CRAMMING
A game rule which regulates the number of entities that can be crammed into a block space before they incur cramming damage. -
DO_WEATHER_CYCLE
-
DO_LIMITED_CRAFTING
-
MAX_COMMAND_CHAIN_LENGTH
-
ANNOUNCE_ADVANCEMENTS
A game rule which regulates whether a player's advancements should be announced in chat. -
DISABLE_RAIDS
A game rule which regulates whether raids should occur.If this rule is set to
truewhile raids are occurring, the raids will be stopped. -
DO_INSOMNIA
-
DO_IMMEDIATE_RESPAWN
A game rule which regulates whether a player should immediately respawn upon death. -
DROWNING_DAMAGE
-
FALL_DAMAGE
-
FIRE_DAMAGE
-
FREEZE_DAMAGE
-
DO_PATROL_SPAWNING
-
DO_TRADER_SPAWNING
-
FORGIVE_DEAD_PLAYERS
-
UNIVERSAL_ANGER
-
PLAYERS_SLEEPING_PERCENTAGE
-
rules
-
-
Constructor Details
-
GameRules
public GameRules(com.mojang.serialization.DynamicLike<?> dynamicLike) -
GameRules
public GameRules() -
GameRules
-
-
Method Details
-
register
private static <T extends GameRules.Rule<T>> GameRules.Key<T> register(String name, GameRules.Category category, GameRules.Type<T> type) -
get
-
toNbt
-
load
private void load(com.mojang.serialization.DynamicLike<?> dynamicLike) -
copy
-
accept
Make the visitor visit all registered game rules.The visitation involves calling both
GameRules.Visitor.visit(GameRules.Key, GameRules.Type)andvisitXfor every game rule, where X is the current rule's concrete type such as a boolean. -
accept
private static <T extends GameRules.Rule<T>> void accept(GameRules.Visitor consumer, GameRules.Key<?> key, GameRules.Type<?> type) -
setAllValues
-
setValue
@Environment(CLIENT) private <T extends GameRules.Rule<T>> void setValue(GameRules.Key<T> key, GameRules rules, @Nullable MinecraftServer server) -
getBoolean
-
getInt
-