Merge branch 'master' into future

This commit is contained in:
gnembon committed 2021-11-30 03:29:24 +01:00
commit 5be52c993c
2 files changed
+22 -2

No files matched your search

+6 -2
View File
@@ -695,9 +695,13 @@ Available options in the scarpet app space:
* `world_folder` - name of the direct folder in the saves that holds world files
* `world_carpet_rules` - returns all Carpet rules in a map form (`rule`->`value`). Note that the values are always returned as strings, so you can't do boolean comparisons directly. Includes rules from extensions with their namespace (`namespace:rule`->`value`). You can later listen to rule changes with the `on_carpet_rule_changes(rule, newValue)` event.
* `world_gamerules` - returns all gamerules in a map form (`rule`->`value`). Like carpet rules, values are returned as strings, so you can use appropriate value conversions using `bool()` or `number()` to convert them to other values. Gamerules are read-only to discourage app programmers to mess up with the settings intentionally applied by server admins. Isn't that just super annoying when a datapack messes up with your gamerule settings? It is still possible to change them though using `run('gamerule ...`.
* `world_spawn_point` - world spawn point
* `world_spawn_point` - world spawn point in the overworld dimension
* `world_time` - Returns dimension-specific tick counter.
* `world_top` - Returns current dimensions' topmost Y value where one can place blocks.
* `world_bottom` - Returns current dimensions' bottommost Y value where one can place blocks.
* `world_center` - Returns coordinates of the center of the world with respect of the world border
* `world_size` - Returns size of the world where at this distance from `world_center` world border appears.
*
Relevant gameplay related properties
* `game_difficulty` - current difficulty of the game: `'peaceful'`, `'easy'`, `'normal'`, or `'hard'`
* `game_hardcore` - boolean whether the game is in hardcore mode
@@ -17,9 +17,13 @@ import com.sun.management.OperatingSystemMXBean;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.ModContainer;
import net.minecraft.SharedConstants;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.WorldSavePath;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.GameRules;
import net.minecraft.world.World;
import net.minecraft.world.WorldProperties;
import net.minecraft.world.border.WorldBorder;
import java.lang.management.ManagementFactory;
import java.nio.file.Path;
@@ -60,6 +64,18 @@ public class SystemInfo {
WorldProperties prop = c.s.getServer().getOverworld().getLevelProperties();
return ListValue.of(NumericValue.of(prop.getSpawnX()), NumericValue.of(prop.getSpawnY()), NumericValue.of(prop.getSpawnZ()));
});
put("world_bottom", c-> new NumericValue(c.s.getWorld().getBottomY()));
put("world_top", c-> new NumericValue(c.s.getWorld().getTopY()));
put("world_center", c-> {
WorldBorder worldBorder = c.s.getWorld().getWorldBorder();
return ListValue.fromTriple(worldBorder.getCenterX(), 0, worldBorder.getCenterZ());
});
put("world_size", c-> new NumericValue( c.s.getWorld().getWorldBorder().getMaxRadius()));
put("world_time", c -> new NumericValue(c.s.getWorld().getTime()));
put("game_difficulty", c -> StringValue.of(c.s.getServer().getSaveProperties().getDifficulty().getName()));