change nbt format

This commit is contained in:
Sen 2025-05-27 21:25:11 +02:00
parent ad4949af16
commit 17aad1f023
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
124 changed files with 2063 additions and 2986 deletions

View file

@ -45,7 +45,8 @@ import common.init.Config.ValueType;
import common.log.Log;
import common.nbt.NBTLoader;
import common.nbt.NBTTagCompound;
import common.nbt.NBTTagList;
import common.nbt.NBTTagDoubleList;
import common.nbt.NBTTagFloatList;
import common.net.bootstrap.ServerBootstrap;
import common.net.channel.Channel;
import common.net.channel.ChannelException;
@ -206,15 +207,15 @@ public final class Server implements IThreadListener {
if(file.exists()) {
try {
NBTTagCompound tag = NBTLoader.readGZip(file);
NBTTagCompound cfg = tag.getCompoundTag("Config");
NBTTagCompound cfg = tag.getTag("Config");
for(String key : cfg.getKeySet()) {
Config.set(key, cfg.getString(key), false);
}
UniverseRegistry.loadNbt(tag.getCompoundTag("Universe"));
UniverseRegistry.loadNbt(tag.getTag("Universe"));
long lastPlayed = tag.getLong("LastAccess");
String version = tag.hasKey("Version", 8) ? tag.getString("Version") : null;
String version = tag.hasString("Version") ? tag.getString("Version") : null;
version = version != null && version.isEmpty() ? "<unbekannt>" : version;
long time = tag.hasKey("Time", 4) ? tag.getLong("Time") : World.START_TIME;
long time = tag.hasLong("Time") ? tag.getLong("Time") : World.START_TIME;
Log.IO.info("Version: %s", version);
Log.IO.info("Weltzeit: %d Ticks / %d Sekunden", time, time / 20L);
Log.IO.info("Zuletzt geladen: %s", new SimpleDateFormat("dd.MM.yyyy HH:mm:ss").format(new Date(lastPlayed)));
@ -328,14 +329,14 @@ public final class Server implements IThreadListener {
NBTTagCompound tag = this.loadPlayerData(user);
if(tag == null)
return null;
NBTTagList pos = tag.getTagList("Pos", 6);
NBTTagList rot = tag.getTagList("Rotation", 5);
double posX = pos.getDoubleAt(0);
double posY = pos.getDoubleAt(1);
double posZ = pos.getDoubleAt(2);
float rotYaw = rot.getFloatAt(0);
float rotPitch = rot.getFloatAt(1);
int dimension = tag.getInteger("Dimension");
NBTTagDoubleList pos = tag.getDoubleList("Pos");
NBTTagFloatList rot = tag.getFloatList("Rotation");
double posX = pos.getDouble(0);
double posY = pos.getDouble(1);
double posZ = pos.getDouble(2);
float rotYaw = rot.getFloat(0);
float rotPitch = rot.getFloat(1);
int dimension = tag.getInt("Dimension");
return new Position(posX, posY, posZ, rotYaw, rotPitch, dimension);
}
@ -871,7 +872,7 @@ public final class Server implements IThreadListener {
this.usermap.put(loginUser, conn);
tag = conn.readCharacter();
WorldServer world = tag == null ? this.space : this.getWorld(tag.getInteger("Dimension"));
WorldServer world = tag == null ? this.space : this.getWorld(tag.getInt("Dimension"));
world = world == null ? this.space : world;
EntityNPC player = conn.createPlayer(world, tag == null ? EntityRegistry.getEntityString(EntityHuman.class) : tag.getString("id"));
if(tag != null)
@ -959,7 +960,7 @@ public final class Server implements IThreadListener {
if(entity != null) {
NBTTagCompound etag = new NBTTagCompound();
entity.writeToNBT(etag);
etag.setInteger("Dimension", entity.worldObj.dimension.getDimensionId());
etag.setInt("Dimension", entity.worldObj.dimension.getDimensionId());
etag.setString("id", EntityRegistry.getEntityString(entity));
conn.writeCharacter(etag);
}
@ -1049,7 +1050,7 @@ public final class Server implements IThreadListener {
old.unmount();
NBTTagCompound oldTag = new NBTTagCompound();
old.writeToNBT(oldTag);
oldTag.setInteger("Dimension", old.worldObj.dimension.getDimensionId());
oldTag.setInt("Dimension", old.worldObj.dimension.getDimensionId());
oldTag.setString("id", EntityRegistry.getEntityString(old));
WorldServer oldWorld = (WorldServer)old.getServerWorld();
@ -1059,7 +1060,7 @@ public final class Server implements IThreadListener {
oldWorld.removePlayerEntityDangerously(old);
// old.dead = false;
WorldServer world = tag == null ? this.space : this.getWorld(tag.getInteger("Dimension"));
WorldServer world = tag == null ? this.space : this.getWorld(tag.getInt("Dimension"));
world = world == null ? this.space : world;
EntityNPC nplayer = conn.createPlayer(world, tag == null ? EntityRegistry.getEntityString(clazz) : tag.getString("id"));
// conn.sendPacket(new SPacketRespawn(world.dimension, EntityRegistry.getEntityID(nplayer)));