converter TEMP
This commit is contained in:
parent
445c1be8af
commit
3a1679f0e9
3 changed files with 47 additions and 134 deletions
|
@ -405,7 +405,7 @@ public final class Server implements IThreadListener, Executor {
|
|||
|
||||
public void run(long time) {
|
||||
Region.loadMap();
|
||||
Converter.convert(this);
|
||||
Converter.convert();
|
||||
long wtime = this.loadServerConfig();
|
||||
if(this.keyPair == null) {
|
||||
Log.SYSTEM.info("Generiere neues Schlüsselpaar");
|
||||
|
|
|
@ -51,10 +51,13 @@ import common.entity.animal.EntitySquid;
|
|||
import common.entity.animal.EntityWolf;
|
||||
import common.entity.item.EntityBoat;
|
||||
import common.entity.item.EntityMinecart;
|
||||
import common.init.BlockRegistry;
|
||||
import common.init.Blocks;
|
||||
import common.init.EntityRegistry;
|
||||
import common.init.TileRegistry;
|
||||
import common.log.Log;
|
||||
import common.properties.Property;
|
||||
import common.properties.PropertyEnum;
|
||||
import common.rng.Random;
|
||||
import common.tags.TagObject;
|
||||
import common.tileentity.TileEntity;
|
||||
|
@ -72,8 +75,6 @@ import common.tileentity.TileEntitySign;
|
|||
import common.util.Facing;
|
||||
import common.util.NibbleArray;
|
||||
import common.world.State;
|
||||
import common.world.Weather;
|
||||
import server.Server;
|
||||
|
||||
public abstract class Converter {
|
||||
private static class NbtTag {
|
||||
|
@ -254,7 +255,6 @@ public abstract class Converter {
|
|||
private static final Map<String, String> ENTITY_MAP = Maps.newHashMap();
|
||||
private static final Map<String, String> TILE_MAP = Maps.newHashMap();
|
||||
private static final char[] BLOCK_MAP = new char[65536];
|
||||
private static final Map<String, String> OLD_GAMERULES = Maps.newHashMap();
|
||||
|
||||
private static void mapEntity(Class<? extends Entity> clazz, String ... names) {
|
||||
String name = EntityRegistry.getEntityString(clazz);
|
||||
|
@ -290,7 +290,13 @@ public abstract class Converter {
|
|||
|
||||
private static void mapBlockData(Block block, int id) {
|
||||
for(int z = 0; z < 16; z++) {
|
||||
mapBlock(block.getStateFromMeta(z), id, z);
|
||||
State state = block.getStateFromMeta(z);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(Entry<Property, Comparable> prop : state.getProperties().entrySet()) {
|
||||
sb.append(".withProperty(").append(block.getClass().getSimpleName()).append('.').append(prop.getKey().getName().toUpperCase()).append(", ").append(prop.getKey() instanceof PropertyEnum penum ? penum.getType().getSimpleName() + "." + ((Enum)prop.getValue()).name() : prop.getValue()).append(')');
|
||||
}
|
||||
Log.IO.debug("mapBlock(Blocks.%s.getState()%s, %d, %d)", BlockRegistry.getNameFromBlock(block), sb.toString(), id, z);
|
||||
mapBlock(state, id, z);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -301,18 +307,6 @@ public abstract class Converter {
|
|||
}
|
||||
|
||||
static {
|
||||
OLD_GAMERULES.put("doFireTick", "fireTick");
|
||||
OLD_GAMERULES.put("mobGriefing", "mobGriefing");
|
||||
OLD_GAMERULES.put("doMobSpawning", "mobSpawning");
|
||||
OLD_GAMERULES.put("doMobLoot", "dropLoot");
|
||||
OLD_GAMERULES.put("doTileDrops", "dropBlocks");
|
||||
OLD_GAMERULES.put("doEntityDrops", "dropObjects");
|
||||
OLD_GAMERULES.put("naturalRegeneration", "naturalRegeneration");
|
||||
OLD_GAMERULES.put("doDaylightCycle", "daylightCycle");
|
||||
OLD_GAMERULES.put("keepInventory", "keepInventory");
|
||||
OLD_GAMERULES.put("doWeatherCycle", "weatherChanges");
|
||||
OLD_GAMERULES.put("randomTickSpeed", "randomTickSpeed");
|
||||
|
||||
mapEntity(EntityBoat.class, "Boat", "boat");
|
||||
mapEntity(EntityMinecart.class, "Minecart", "MinecartRideable", "minecart");
|
||||
mapEntity(EntityBat.class, "Bat", "bat");
|
||||
|
@ -707,7 +701,7 @@ public abstract class Converter {
|
|||
mapBlockData(Blocks.carrot, 141);
|
||||
mapBlockData(Blocks.potato, 142);
|
||||
mapBlockData(Blocks.wooden_button, 143);
|
||||
mapBlockData(Blocks.skull, 144); // -NODROP
|
||||
mapBlockData(Blocks.skull, 144);
|
||||
mapBlockData(Blocks.anvil, 145);
|
||||
mapBlockData(Blocks.trapped_chest, 146);
|
||||
mapBlockData(Blocks.light_weighted_pressure_plate, 147);
|
||||
|
@ -854,6 +848,8 @@ public abstract class Converter {
|
|||
}
|
||||
}, 252);
|
||||
mapBlock(Blocks.obsidian, 255);
|
||||
|
||||
Log.IO.debug("Hash: %08x", Arrays.hashCode(BLOCK_MAP));
|
||||
}
|
||||
|
||||
private static Object read(DataInput input, byte id) throws IOException {
|
||||
|
@ -1170,9 +1166,6 @@ public abstract class Converter {
|
|||
NbtTag tag = readTag(in);
|
||||
in.close();
|
||||
TagObject ntag = convertChunkData(tag, legacy);
|
||||
// DataOutputStream out = newreg.getOutputStream(nx, nz);
|
||||
// CompressedStreamTools.write(tag, out);
|
||||
// out.close();
|
||||
newreg.writeTag(nx, nz, ntag);
|
||||
}
|
||||
}
|
||||
|
@ -1183,7 +1176,6 @@ public abstract class Converter {
|
|||
if(percent > prev) {
|
||||
start = postProgress(start, percent);
|
||||
}
|
||||
// this.doneChunks += 1;
|
||||
}
|
||||
}
|
||||
oldreg.close();
|
||||
|
@ -1195,7 +1187,7 @@ public abstract class Converter {
|
|||
return start;
|
||||
}
|
||||
|
||||
public static boolean convert(Server server) {
|
||||
public static boolean convert() {
|
||||
long cur = System.currentTimeMillis();
|
||||
if(new File("server.cdt").exists())
|
||||
return false;
|
||||
|
@ -1232,61 +1224,41 @@ public abstract class Converter {
|
|||
return false;
|
||||
}
|
||||
Log.IO.info("Version: %s", ver);
|
||||
if(ver != SaveVersion.RELEASE_1_13) {
|
||||
Log.IO.info("Konvertiere Chunk-Daten von region/*.mca,*.mcr");
|
||||
File regionDir = new File("region");
|
||||
if(regionDir.exists()) {
|
||||
File chunkDir = new File(new File("chunk"), "terra");
|
||||
Log.IO.info("Konvertiere Welt nach '" + chunkDir + "' ...");
|
||||
Log.IO.info("Durchsuche Ordner unter '" + regionDir + "' nach .mca- und .mcr-Dateien ...");
|
||||
File[] files = regionDir.listFiles(new FilenameFilter() {
|
||||
public boolean accept(File file, String name) {
|
||||
return name.endsWith(".mca") || name.endsWith(".mcr");
|
||||
}
|
||||
});
|
||||
if(files.length == 0) {
|
||||
Log.IO.info("Keine .mca- oder .mcr-Dateien gefunden.");
|
||||
}
|
||||
else {
|
||||
Log.IO.info("Ingesamt wurden " + files.length + " .mca-Dateien und .mcr-Dateien gefunden, konvertiere ...");
|
||||
if(ver == SaveVersion.RELEASE_1_9)
|
||||
Log.IO.info("Konvertiere von neuerer Version, dies wird Blöcke entfernen ...");
|
||||
chunkDir.mkdirs();
|
||||
int progress = 0;
|
||||
long time = System.currentTimeMillis();
|
||||
long start = postProgress(time, 0);
|
||||
for(File file : files) {
|
||||
int percent = (int)Math.round(100.0D * (double)progress / (double)files.length);
|
||||
Log.IO.info("Konvertiere Chunk-Daten: " + file.getName() + " (" + progress + "/" + files.length + ")");
|
||||
start = convertChunks(chunkDir, file, start, progress, files.length);
|
||||
++progress;
|
||||
start = postProgress(start, percent);
|
||||
}
|
||||
time = System.currentTimeMillis() - time;
|
||||
Log.IO.info("Fertig. Konversion dauerte " + ((time / 60000L) > 0 ? ((time / 60000L) + " Minuten und ") : "") + ((time / 1000L) % 60L) + " Sekunden.");
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(ver == SaveVersion.RELEASE_1_13) {
|
||||
Log.IO.warn("Konvertiere keine Chunk-Daten, da Version zu neu");
|
||||
return false;
|
||||
}
|
||||
Log.IO.info("Konvertiere Daten von level.dat");
|
||||
NbtTag rules = tag.getTag("GameRules");
|
||||
for(Entry<String, String> rule : OLD_GAMERULES.entrySet()) {
|
||||
if(!rules.getString(rule.getKey()).isEmpty())
|
||||
server.getVariables().get(rule.getValue()).set(rules.getString(rule.getKey()), false, false);
|
||||
}
|
||||
Weather weather = tag.getByte("thundering") != 0 ? Weather.THUNDER : (tag.getByte("raining") != 0 ? Weather.RAIN : Weather.CLEAR);
|
||||
if(weather != Weather.CLEAR) {
|
||||
TagObject dataTag = new TagObject();
|
||||
dataTag.setString("Weather", weather.getName());
|
||||
Log.IO.info("Speichere neue data.cdt ...");
|
||||
File dataFile = new File(new File(new File("chunk"), "terra"), "data.cdt");
|
||||
try {
|
||||
TagObject.writeGZip(dataTag, dataFile);
|
||||
Log.IO.info("Konvertiere Chunk-Daten von region/*.mca,*.mcr");
|
||||
File regionDir = new File("region");
|
||||
if(regionDir.exists()) {
|
||||
File chunkDir = new File(new File("chunk"), "terra");
|
||||
Log.IO.info("Konvertiere Welt nach '" + chunkDir + "' ...");
|
||||
Log.IO.info("Durchsuche Ordner unter '" + regionDir + "' nach .mca- und .mcr-Dateien ...");
|
||||
File[] files = regionDir.listFiles(new FilenameFilter() {
|
||||
public boolean accept(File file, String name) {
|
||||
return name.endsWith(".mca") || name.endsWith(".mcr");
|
||||
}
|
||||
});
|
||||
if(files.length == 0) {
|
||||
Log.IO.info("Keine .mca- oder .mcr-Dateien gefunden.");
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.IO.error(e, "Konnte Weltdaten nicht speichern");
|
||||
else {
|
||||
Log.IO.info("Ingesamt wurden " + files.length + " .mca-Dateien und .mcr-Dateien gefunden, konvertiere ...");
|
||||
if(ver == SaveVersion.RELEASE_1_9)
|
||||
Log.IO.info("Konvertiere von neuerer Version, dies wird Blöcke entfernen ...");
|
||||
chunkDir.mkdirs();
|
||||
int progress = 0;
|
||||
long time = System.currentTimeMillis();
|
||||
long start = postProgress(time, 0);
|
||||
for(File file : files) {
|
||||
int percent = (int)Math.round(100.0D * (double)progress / (double)files.length);
|
||||
Log.IO.info("Konvertiere Chunk-Daten: " + file.getName() + " (" + progress + "/" + files.length + ")");
|
||||
start = convertChunks(chunkDir, file, start, progress, files.length);
|
||||
++progress;
|
||||
start = postProgress(start, percent);
|
||||
}
|
||||
time = System.currentTimeMillis() - time;
|
||||
Log.IO.info("Fertig. Konversion dauerte " + ((time / 60000L) > 0 ? ((time / 60000L) + " Minuten und ") : "") + ((time / 1000L) % 60L) + " Sekunden.");
|
||||
}
|
||||
}
|
||||
Log.IO.info("Einstiegspunkt: /tele %d %d %d terra", tag.getInt("SpawnX"), tag.getInt("SpawnY"), tag.getInt("SpawnZ"));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue