GameRuleCategory .java

net.minecraft.world.level.gamerules.GameRuleCategory (record): members: SORT_ORDER, SPAWNING, UPDATES, DROPS, MOBS, CHAT, MISC, getDescriptionId, PLAYER.

net.minecraft.world.level.gamerulesrecord42 linescommon1.4 KB

API Surface (4)

record GameRuleCategory(Identifier id)
Identifier getDescriptionId()
GameRuleCategory register(final Identifier id)
MutableComponent label()

Fields & Constants (8)

SORT_ORDER
PLAYER
MOBS
SPAWNING
DROPS
UPDATES
CHAT
MISC

String literals (8)

"player"
"mobs"
"spawning"
"drops"
"updates"
"chat"
"misc"
"gamerule.category"

Code Graph: Dependencies (3)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

GameRuleCategory.java42 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.level.gamerules;
2
3
import java.util.ArrayList;
4
import java.util.List;
5
import java.util.Locale;
6
import net.minecraft.network.chat.Component;
7
import net.minecraft.network.chat.MutableComponent;
8
import net.minecraft.resources.Identifier;
9
10
public record GameRuleCategory(Identifier id) {
11
	private static final List<GameRuleCategory> SORT_ORDER = new ArrayList<>();
12
	public static final GameRuleCategory PLAYER = register("player");
13
	public static final GameRuleCategory MOBS = register("mobs");
14
	public static final GameRuleCategory SPAWNING = register("spawning");
15
	public static final GameRuleCategory DROPS = register("drops");
16
	public static final GameRuleCategory UPDATES = register("updates");
17
	public static final GameRuleCategory CHAT = register("chat");
18
	public static final GameRuleCategory MISC = register("misc");
19
20
	public Identifier getDescriptionId() {
21
		return this.id;
22
	}
23
24
	private static GameRuleCategory register(final String name) {
25
		return register(Identifier.withDefaultNamespace(name));
26
	}
27
28
	public static GameRuleCategory register(final Identifier id) {
29
		GameRuleCategory category = new GameRuleCategory(id);
30
		if (SORT_ORDER.contains(category)) {
31
			throw new IllegalArgumentException(String.format(Locale.ROOT, "Category '%s' is already registered.", id));
32
		}
33
34
		SORT_ORDER.add(category);
35
		return category;
36
	}
37
38
	public MutableComponent label() {
39
		return Component.translatable(this.id.toLanguageKey("gamerule.category"));
40
	}
41
}
42

Decompiled Minecraft 26.3 source of GameRuleCategory (net/minecraft/world/level/gamerules/GameRuleCategory.java) with Mojang official mappings, stored verbatim on the site.