Migrate the Carpet codebase to Mojang Mappings
This commit is contained in:
346 files changed
+8353
-8492
No files matched your search
@@ -18,12 +18,11 @@ import com.sun.management.OperatingSystemMXBean;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.fabricmc.loader.api.ModContainer;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.util.WorldSavePath;
|
||||
import net.minecraft.util.math.Vec2f;
|
||||
import net.minecraft.world.GameRules;
|
||||
import net.minecraft.world.WorldProperties;
|
||||
import net.minecraft.world.border.WorldBorder;
|
||||
|
||||
import net.minecraft.world.level.GameRules;
|
||||
import net.minecraft.world.level.border.WorldBorder;
|
||||
import net.minecraft.world.level.storage.LevelData;
|
||||
import net.minecraft.world.level.storage.LevelResource;
|
||||
import net.minecraft.world.phys.Vec2;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
@@ -47,65 +46,65 @@ public class SystemInfo {
|
||||
put("app_scope", c -> StringValue.of((c.host).isPerUser()?"player":"global"));
|
||||
put("app_players", c -> ListValue.wrap(c.host.getUserList().stream().map(StringValue::new).collect(Collectors.toList())));
|
||||
|
||||
put("world_name", c -> new StringValue(c.s.getServer().getSaveProperties().getLevelName()));
|
||||
put("world_seed", c -> new NumericValue(c.s.getWorld().getSeed()));
|
||||
put("server_motd", c -> StringValue.of(c.s.getServer().getServerMotd()));
|
||||
put("world_path", c -> StringValue.of(c.s.getServer().getSavePath(WorldSavePath.ROOT).toString()));
|
||||
put("world_name", c -> new StringValue(c.s.getServer().getWorldData().getLevelName()));
|
||||
put("world_seed", c -> new NumericValue(c.s.getLevel().getSeed()));
|
||||
put("server_motd", c -> StringValue.of(c.s.getServer().getMotd()));
|
||||
put("world_path", c -> StringValue.of(c.s.getServer().getWorldPath(LevelResource.ROOT).toString()));
|
||||
put("world_folder", c -> {
|
||||
Path serverPath = c.s.getServer().getSavePath(WorldSavePath.ROOT);
|
||||
Path serverPath = c.s.getServer().getWorldPath(LevelResource.ROOT);
|
||||
int nodeCount = serverPath.getNameCount();
|
||||
if (nodeCount < 2) return Value.NULL;
|
||||
String tlf = serverPath.getName(nodeCount-2).toString();
|
||||
return StringValue.of(tlf);
|
||||
});
|
||||
put("world_dimensions", c -> ListValue.wrap(c.s.getServer().getWorldRegistryKeys().stream().map(k -> ValueConversions.of(k.getValue())).collect(Collectors.toList())));
|
||||
put("world_dimensions", c -> ListValue.wrap(c.s.getServer().levelKeys().stream().map(k -> ValueConversions.of(k.location())).collect(Collectors.toList())));
|
||||
put("world_spawn_point", c -> {
|
||||
WorldProperties prop = c.s.getServer().getOverworld().getLevelProperties();
|
||||
return ListValue.of(NumericValue.of(prop.getSpawnX()), NumericValue.of(prop.getSpawnY()), NumericValue.of(prop.getSpawnZ()));
|
||||
LevelData prop = c.s.getServer().overworld().getLevelData();
|
||||
return ListValue.of(NumericValue.of(prop.getXSpawn()), NumericValue.of(prop.getYSpawn()), NumericValue.of(prop.getZSpawn()));
|
||||
});
|
||||
|
||||
put("world_bottom", c-> new NumericValue(c.s.getWorld().getBottomY()));
|
||||
put("world_bottom", c-> new NumericValue(c.s.getLevel().getMinBuildHeight()));
|
||||
|
||||
put("world_top", c-> new NumericValue(c.s.getWorld().getTopY()));
|
||||
put("world_top", c-> new NumericValue(c.s.getLevel().getMaxBuildHeight()));
|
||||
|
||||
put("world_center", c-> {
|
||||
WorldBorder worldBorder = c.s.getWorld().getWorldBorder();
|
||||
WorldBorder worldBorder = c.s.getLevel().getWorldBorder();
|
||||
return ListValue.fromTriple(worldBorder.getCenterX(), 0, worldBorder.getCenterZ());
|
||||
});
|
||||
|
||||
put("world_size", c -> new NumericValue(c.s.getWorld().getWorldBorder().getSize() / 2));
|
||||
put("world_size", c -> new NumericValue(c.s.getLevel().getWorldBorder().getSize() / 2));
|
||||
|
||||
put("world_max_size", c-> new NumericValue( c.s.getWorld().getWorldBorder().getMaxRadius()));
|
||||
put("world_max_size", c-> new NumericValue( c.s.getLevel().getWorldBorder().getAbsoluteMaxSize()));
|
||||
|
||||
put("world_time", c -> new NumericValue(c.s.getWorld().getTime()));
|
||||
put("world_time", c -> new NumericValue(c.s.getLevel().getGameTime()));
|
||||
|
||||
put("game_difficulty", c -> StringValue.of(c.s.getServer().getSaveProperties().getDifficulty().getName()));
|
||||
put("game_hardcore", c -> BooleanValue.of(c.s.getServer().getSaveProperties().isHardcore()));
|
||||
put("game_storage_format", c -> StringValue.of(c.s.getServer().getSaveProperties().getFormatName(c.s.getServer().getSaveProperties().getVersion())));
|
||||
put("game_default_gamemode", c -> StringValue.of(c.s.getServer().getDefaultGameMode().getName()));
|
||||
put("game_max_players", c -> new NumericValue(c.s.getServer().getMaxPlayerCount()));
|
||||
put("game_view_distance", c -> new NumericValue(c.s.getServer().getPlayerManager().getViewDistance()));
|
||||
put("game_difficulty", c -> StringValue.of(c.s.getServer().getWorldData().getDifficulty().getKey()));
|
||||
put("game_hardcore", c -> BooleanValue.of(c.s.getServer().getWorldData().isHardcore()));
|
||||
put("game_storage_format", c -> StringValue.of(c.s.getServer().getWorldData().getStorageVersionName(c.s.getServer().getWorldData().getVersion())));
|
||||
put("game_default_gamemode", c -> StringValue.of(c.s.getServer().getDefaultGameType().getName()));
|
||||
put("game_max_players", c -> new NumericValue(c.s.getServer().getMaxPlayers()));
|
||||
put("game_view_distance", c -> new NumericValue(c.s.getServer().getPlayerList().getViewDistance()));
|
||||
put("game_mod_name", c -> StringValue.of(c.s.getServer().getServerModName()));
|
||||
put("game_version", c -> StringValue.of(c.s.getServer().getVersion()));
|
||||
put("game_target", c -> StringValue.of(SharedConstants.getGameVersion().getReleaseTarget()));
|
||||
put("game_version", c -> StringValue.of(c.s.getServer().getServerVersion()));
|
||||
put("game_target", c -> StringValue.of(SharedConstants.getCurrentVersion().getReleaseTarget()));
|
||||
put("game_protocol", c -> NumericValue.of(SharedConstants.getProtocolVersion()));
|
||||
put("game_major_target", c -> {
|
||||
String [] vers = SharedConstants.getGameVersion().getReleaseTarget().split("\\.");
|
||||
String [] vers = SharedConstants.getCurrentVersion().getReleaseTarget().split("\\.");
|
||||
return NumericValue.of((vers.length > 1)?Integer.parseInt(vers[1]):0);
|
||||
});
|
||||
put("game_minor_target", c -> {
|
||||
String [] vers = SharedConstants.getGameVersion().getReleaseTarget().split("\\.");
|
||||
String [] vers = SharedConstants.getCurrentVersion().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("game_stable", c -> BooleanValue.of(SharedConstants.getCurrentVersion().isStable()));
|
||||
put("game_data_version", c->NumericValue.of(SharedConstants.getCurrentVersion().getWorldVersion()));
|
||||
put("game_pack_version", c->NumericValue.of(SharedConstants.getCurrentVersion().getPackVersion()));
|
||||
|
||||
put("server_ip", c -> StringValue.of(c.s.getServer().getServerIp()));
|
||||
put("server_ip", c -> StringValue.of(c.s.getServer().getLocalIp()));
|
||||
put("server_whitelisted", c -> BooleanValue.of(c.s.getServer().isEnforceWhitelist()));
|
||||
put("server_whitelist", c -> {
|
||||
MapValue whitelist = new MapValue(Collections.emptyList());
|
||||
for (String s: c.s.getServer().getPlayerManager().getWhitelistedNames())
|
||||
for (String s: c.s.getServer().getPlayerList().getWhiteListNames())
|
||||
{
|
||||
whitelist.append(StringValue.of(s));
|
||||
}
|
||||
@@ -113,7 +112,7 @@ public class SystemInfo {
|
||||
});
|
||||
put("server_banned_players", c -> {
|
||||
MapValue whitelist = new MapValue(Collections.emptyList());
|
||||
for (String s: c.s.getServer().getPlayerManager().getUserBanList().getNames())
|
||||
for (String s: c.s.getServer().getPlayerList().getBans().getUserList())
|
||||
{
|
||||
whitelist.append(StringValue.of(s));
|
||||
}
|
||||
@@ -121,7 +120,7 @@ public class SystemInfo {
|
||||
});
|
||||
put("server_banned_ips", c -> {
|
||||
MapValue whitelist = new MapValue(Collections.emptyList());
|
||||
for (String s: c.s.getServer().getPlayerManager().getIpBanList().getNames())
|
||||
for (String s: c.s.getServer().getPlayerList().getIpBans().getUserList())
|
||||
{
|
||||
whitelist.append(StringValue.of(s));
|
||||
}
|
||||
@@ -137,9 +136,9 @@ public class SystemInfo {
|
||||
put("server_last_tick_times", c -> {
|
||||
//assuming we are in the tick world section
|
||||
// might be off one tick when run in the off tasks or asynchronously.
|
||||
int currentReportedTick = c.s.getServer().getTicks()-1;
|
||||
int currentReportedTick = c.s.getServer().getTickCount()-1;
|
||||
List<Value> ticks = new ArrayList<>(100);
|
||||
final long[] tickArray = c.s.getServer().lastTickLengths;
|
||||
final long[] tickArray = c.s.getServer().tickTimes;
|
||||
for (int i=currentReportedTick+100; i > currentReportedTick; i--)
|
||||
{
|
||||
ticks.add(new NumericValue(((double)tickArray[i % 100])/1000000.0));
|
||||
@@ -191,11 +190,11 @@ public class SystemInfo {
|
||||
});
|
||||
put("world_gamerules", c->{
|
||||
Map<Value, Value> rules = new HashMap<>();
|
||||
final GameRules gameRules = c.s.getWorld().getGameRules();
|
||||
GameRules.accept(new GameRules.Visitor() {
|
||||
final GameRules gameRules = c.s.getLevel().getGameRules();
|
||||
GameRules.visitGameRuleTypes(new GameRules.GameRuleTypeVisitor() {
|
||||
@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()));
|
||||
public <T extends GameRules.Value<T>> void visit(GameRules.Key<T> key, GameRules.Type<T> type) {
|
||||
rules.put(StringValue.of(key.getId()), StringValue.of(gameRules.getRule(key).toString()));
|
||||
}
|
||||
});
|
||||
return MapValue.wrap(rules);
|
||||
@@ -203,9 +202,9 @@ public class SystemInfo {
|
||||
|
||||
put("source_entity", c -> EntityValue.of(c.s.getEntity()));
|
||||
put("source_position", c -> ValueConversions.of(c.s.getPosition()));
|
||||
put("source_dimension", c -> ValueConversions.of(c.s.getWorld()));
|
||||
put("source_dimension", c -> ValueConversions.of(c.s.getLevel()));
|
||||
put("source_rotation", c -> {
|
||||
Vec2f rotation = c.s.getRotation();
|
||||
Vec2 rotation = c.s.getRotation();
|
||||
return ListValue.of(new NumericValue(rotation.x), new NumericValue(rotation.y));
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user