Skip to content

Commit

Permalink
Add game rule data
Browse files Browse the repository at this point in the history
  • Loading branch information
Nickid2018 committed Oct 1, 2024
1 parent 6be743d commit 00c93b6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class GameRuleDataExtractor {

public static final StringWikiData GAME_RULE_CATEGORY = new StringWikiData();
public static final StringWikiData GAME_RULE_DEFAULT_VALUE = new StringWikiData();
public static final DoubleNumberWikiData GAME_RULE_RANGE = new DoubleNumberWikiData();
public static final StringWikiData GAME_RULE_TYPE = new StringWikiData();

@SneakyThrows
public static void extractGameRuleData(MinecraftServer serverObj) {
Expand All @@ -25,6 +25,7 @@ public void visitBoolean(GameRules.Key<GameRules.BooleanValue> key, GameRules.Ty
String name = key.getId();
GameRules.Category category = key.getCategory();
GAME_RULE_CATEGORY.put(name, category.name());
GAME_RULE_TYPE.put(name, "bool");
GameRules.BooleanValue value = type.createRule();
GAME_RULE_DEFAULT_VALUE.put(name, String.valueOf(value.get()));
}
Expand All @@ -34,15 +35,13 @@ public void visitInteger(GameRules.Key<GameRules.IntegerValue> key, GameRules.Ty
String name = key.getId();
GameRules.Category category = key.getCategory();
GAME_RULE_CATEGORY.put(name, category.name());
GAME_RULE_TYPE.put(name, "int");
GameRules.IntegerValue value = type.createRule();
GAME_RULE_DEFAULT_VALUE.put(name, String.valueOf(value.get()));
RequiredArgumentBuilder<CommandSourceStack, ?> arg = type.createArgument("test");
IntegerArgumentType argType = (IntegerArgumentType) arg.getType();
GAME_RULE_RANGE.put(name, argType.getMinimum(), argType.getMaximum());
}
});
WikiData.write(GAME_RULE_TYPE, "game_rule_type.txt");
WikiData.write(GAME_RULE_CATEGORY, "game_rule_category.txt");
WikiData.write(GAME_RULE_DEFAULT_VALUE, "game_rule_default_value.txt");
WikiData.write(GAME_RULE_RANGE, "game_rule_range.txt");
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package net.minecraft.world.level;

import net.minecraft.commands.CommandSourceStack;
import com.mojang.brigadier.builder.RequiredArgumentBuilder;

public class GameRules {

public void visitGameRuleTypes(GameRuleTypeVisitor gameRuleTypeVisitor) {
Expand Down Expand Up @@ -40,10 +37,6 @@ public static class Type<T extends Value<T>> {
public T createRule() {
throw new RuntimeException();
}

public RequiredArgumentBuilder<CommandSourceStack, ?> createArgument(String string) {
throw new RuntimeException();
}
}

public static abstract class Value<T extends Value<T>> {
Expand Down

0 comments on commit 00c93b6

Please sign in to comment.