Adding Gamerule modification to scarpet (#610)
This commit is contained in:
1 parent
b318f1fb68
commit
49e5c012b3
3 files changed
+16
-5
No files matched your search
@@ -13,6 +13,7 @@ import carpet.settings.ParsedRule;
|
||||
import carpet.settings.SettingsManager;
|
||||
import com.sun.management.OperatingSystemMXBean;
|
||||
import net.minecraft.util.WorldSavePath;
|
||||
import net.minecraft.world.GameRules;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.nio.file.Path;
|
||||
@@ -124,6 +125,17 @@ public class SystemInfo {
|
||||
});
|
||||
return carpetRules;
|
||||
});
|
||||
put("world_gamerules", c->{
|
||||
Map<Value, Value> rules = new HashMap<>();
|
||||
final GameRules gameRules = c.s.getWorld().getGameRules();
|
||||
GameRules.accept(new GameRules.Visitor() {
|
||||
@Override
|
||||
public <T extends GameRules.Rule<T>> void visit(GameRules.Key<T> key, GameRules.Type<T> type) {
|
||||
rules.put(StringValue.of(key.getName()), StringValue.of(gameRules.get(key).toString()));
|
||||
}
|
||||
});
|
||||
return MapValue.wrap(rules);
|
||||
});
|
||||
put("scarpet_version", c -> StringValue.of(CarpetSettings.carpetVersion));
|
||||
|
||||
}};
|
||||
|
||||
Reference in new issue
Block a user