Adding min_y, max_y and world_border_info to system_info (#1168)

* Adding min_y and max_y

* Making it return all dimensions

* Adding world_border_info as well, cos y not

* Update docs/scarpet/api/Auxiliary.md

Co-authored-by: gnembon <41132274+gnembon@users.noreply.github.com>

Co-authored-by: gnembon <41132274+gnembon@users.noreply.github.com>
This commit is contained in:
Ghoulboyandgnembon authored and GitHub committed 2021-11-30 03:03:15 +01:00
1 parent 16e1b7952e
commit 6c776b6131
2 files changed
+40 -1

No files matched your search

@@ -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,38 @@ 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_min_height", c-> {
Map<Value, Value> dimMap = new HashMap<>();
for (ServerWorld world : c.s.getServer().getWorlds()) {
dimMap.put(ValueConversions.of(world.getRegistryKey().getValue()), new NumericValue(world.getBottomY()));
}
return MapValue.wrap(dimMap);
});
put("world_max_height", c-> {
Map<Value, Value> dimMap = new HashMap<>();
for (ServerWorld world : c.s.getServer().getWorlds()) {
dimMap.put(ValueConversions.of(world.getRegistryKey().getValue()), new NumericValue(world.getLogicalHeight()));
}
return MapValue.wrap(dimMap);
});
put("world_border_info", c-> {
Map<Value, Value> dimMap = new HashMap<>();
for (ServerWorld world : c.s.getServer().getWorlds()) {
WorldBorder worldBorder = world.getWorldBorder();
dimMap.put(
ValueConversions.of(world.getRegistryKey().getValue()),
ListValue.of(
ListValue.fromTriple(worldBorder.getCenterX(), 0, worldBorder.getCenterZ()),
new NumericValue(worldBorder.getMaxRadius())
)
);
}
return MapValue.wrap(dimMap);
});
put("world_time", c -> new NumericValue(c.s.getWorld().getTime()));
put("game_difficulty", c -> StringValue.of(c.s.getServer().getSaveProperties().getDifficulty().getName()));