diff --git a/docs/scarpet/api/Auxiliary.md b/docs/scarpet/api/Auxiliary.md index 952e0f15..466e9ec6 100644 --- a/docs/scarpet/api/Auxiliary.md +++ b/docs/scarpet/api/Auxiliary.md @@ -621,7 +621,13 @@ 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_target` - target release version + * `game_major_target` - major release target. For 1.12.2, that would be 12 + * `game_minor_reease` - minor release target. For 1.12.2, that woudl be 2 + * `game_protocol` - protocol version number + * `game_pack_version` - datapack version number * `game_data_version` - data version of the game. Returns an integer, so it can be compared. + * `game_stable` - indicating if its a production release or a snapshot 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 79dd6b1a..18c69d3e 100644 --- a/src/main/java/carpet/script/utils/SystemInfo.java +++ b/src/main/java/carpet/script/utils/SystemInfo.java @@ -4,6 +4,7 @@ import carpet.CarpetServer; import carpet.CarpetSettings; import carpet.script.CarpetContext; import carpet.script.CarpetScriptHost; +import carpet.script.value.BooleanValue; import carpet.script.value.ListValue; import carpet.script.value.MapValue; import carpet.script.value.NumericValue; @@ -59,7 +60,19 @@ 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_target", c -> StringValue.of(SharedConstants.getGameVersion().getReleaseTarget())); + put("game_protocol", c -> NumericValue.of(SharedConstants.method_31372())); + put("game_major_target", c -> { + String [] vers = SharedConstants.getGameVersion().getReleaseTarget().split("\\."); + return NumericValue.of((vers.length > 1)?Integer.parseInt(vers[1]):0); + }); + put("game_minor_target", c -> { + String [] vers = SharedConstants.getGameVersion().getReleaseTarget().split("\\."); + return NumericValue.of((vers.length > 2)?Integer.parseInt(vers[2]):0); + }); + put("game_stable", c -> BooleanValue.of(SharedConstants.getGameVersion().isStable())); put("game_data_version", c->NumericValue.of(SharedConstants.getGameVersion().getWorldVersion())); + put("game_pack_version", c->NumericValue.of(SharedConstants.getGameVersion().getPackVersion())); put("server_ip", c -> StringValue.of(c.s.getMinecraftServer().getServerIp())); put("server_whitelisted", c -> new NumericValue(c.s.getMinecraftServer().isEnforceWhitelist())); diff --git a/src/main/java/carpet/script/value/BooleanValue.java b/src/main/java/carpet/script/value/BooleanValue.java index ea67f11b..19a9bc05 100644 --- a/src/main/java/carpet/script/value/BooleanValue.java +++ b/src/main/java/carpet/script/value/BooleanValue.java @@ -16,6 +16,11 @@ public class BooleanValue extends NumericValue boolValue = boolval; } + public static BooleanValue of(boolean value) + { + return value?TRUE:FALSE; + } + @Override public String getString() { return boolValue?"true":"false";