From 6375108dbf204ef0ea06379c2cbebb7351c7ff80 Mon Sep 17 00:00:00 2001 From: Ghoulboy78 Date: Mon, 28 Dec 2020 10:28:20 +0100 Subject: [PATCH] Add game_data_version (it's mostly for WE dev, ngl) --- docs/scarpet/api/Auxiliary.md | 5 +++-- src/main/java/carpet/script/utils/SystemInfo.java | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/scarpet/api/Auxiliary.md b/docs/scarpet/api/Auxiliary.md index 3db7a3df..e7c5c7ff 100644 --- a/docs/scarpet/api/Auxiliary.md +++ b/docs/scarpet/api/Auxiliary.md @@ -488,7 +488,7 @@ it could either mean your input is wrong, or statistic effectively has a value o ### `system_info()`, `system_info(property)` Fetches the value of a system property or returns all inforation as a map when called without any arguments. It can be used to fetch various information, mostly not changing, or only available via low level -system calls. In all cirumstances, these are only provided as read-only. +system calls. In all circumstances, these are only provided as read-only. Available options in the scarpet app space: * `app_name` - current app name or `null` if its a default app @@ -506,7 +506,7 @@ Available options in the scarpet app space: Relevant gameplay related properties - * `game_difficulty` - current difficulty of the game: `'peacefu'`, `'easy'`, `'normal'`, or `'hard'` + * `game_difficulty` - current difficulty of the game: `'peaceful'`, `'easy'`, `'normal'`, or `'hard'` * `game_hardcore` - boolean whether the game is in hardcore mode * `game_storage_format` - format of the world save files, either `'McRegion'` or `'Anvil'` * `game_default_gamemode` - default gamemode for new players @@ -514,6 +514,7 @@ Available options in the scarpet app space: * `game_view_distance` - the view distance * `game_mod_name` - the name of the base mod. Expect `'fabric'` * `game_version` - base version of the game + * `game_data_version` - data version of the game. Returns an integer, so it can be compared. Server related properties * `server_motd` - the motd of the server visible when joining diff --git a/src/main/java/carpet/script/utils/SystemInfo.java b/src/main/java/carpet/script/utils/SystemInfo.java index 8d1ac7c2..230fbac5 100644 --- a/src/main/java/carpet/script/utils/SystemInfo.java +++ b/src/main/java/carpet/script/utils/SystemInfo.java @@ -13,6 +13,7 @@ import carpet.settings.ParsedRule; import carpet.settings.SettingsManager; import com.sun.management.OperatingSystemMXBean; import net.fabricmc.loader.api.FabricLoader; +import net.minecraft.SharedConstants; import net.minecraft.util.WorldSavePath; import net.minecraft.world.GameRules; @@ -56,6 +57,7 @@ public class SystemInfo { put("game_view_distance", c -> new NumericValue(c.s.getMinecraftServer().getPlayerManager().getViewDistance())); put("game_mod_name", c -> StringValue.of(c.s.getMinecraftServer().getServerModName())); put("game_version", c -> StringValue.of(c.s.getMinecraftServer().getVersion())); + put("game_data_version", c->NumericValue.of(SharedConstants.getGameVersion().getWorldVersion())); put("server_ip", c -> StringValue.of(c.s.getMinecraftServer().getServerIp())); put("server_whitelisted", c -> new NumericValue(c.s.getMinecraftServer().isEnforceWhitelist()));