From 90de256e0480a612c6e021a2269aed0799c0bca1 Mon Sep 17 00:00:00 2001 From: Sen Date: Sun, 16 Mar 2025 21:58:40 +0100 Subject: [PATCH] loading gui + converter --- java/src/game/Game.java | 64 +++--- java/src/game/gui/Gui.java | 24 +- java/src/game/gui/world/GuiEdit.java | 4 +- java/src/game/gui/world/GuiWorlds.java | 12 +- java/src/game/renderer/Drawing.java | 32 +++ java/src/game/world/Converter.java | 297 +++++++++++++++---------- java/src/game/world/WorldClient.java | 4 + 7 files changed, 259 insertions(+), 178 deletions(-) diff --git a/java/src/game/Game.java b/java/src/game/Game.java index e68e19a..75d5b1e 100755 --- a/java/src/game/Game.java +++ b/java/src/game/Game.java @@ -63,6 +63,7 @@ import game.gui.Gui; import game.gui.GuiConsole; import game.gui.GuiGameOver; import game.gui.GuiInfo; +import game.gui.GuiLoading; import game.gui.GuiMenu; import game.gui.Style; import game.gui.container.GuiContainer; @@ -933,6 +934,8 @@ public class Game implements IThreadListener { } if(this.open != null) this.open.render(); + else if(this.theWorld == null || this.theWorld.hasNoChunks()) + Drawing.drawScaledBackground(this, Gui.DIRT_BACKGROUND); if(Bind.INFO.isDown() && (this.open == null || !(this.open.selected instanceof Textbox))) this.drawInfo(); if(this.hudOverlay && !(this.open instanceof GuiConsole)) @@ -958,7 +961,7 @@ public class Game implements IThreadListener { int y1 = 0; int y2 = this.fb_y; // int pos = 0; - String str = this.getldebug(); + String str = this.getLeft(this.server); // if(jstr) // str = (*jsys.env)->GetStringUTFChars(jsys.env, jstr, NULL); // elem->r_dirty = 1; @@ -2118,30 +2121,32 @@ public class Game implements IThreadListener { if(Bind.FULLSCREEN.isPressed()) { this.full(!this.fullscreen); } - if(!(this.open instanceof GuiConsole) && Bind.COMMAND.isPressed()) { - this.displayGuiScreen(GuiConsole.INSTANCE); - } -// if(this.theWorld != null && this.open == null && Bind.COMMAND.isPressed()) { -// this.displayGuiScreen(GuiChat.INSTANCE); -// } - if(this.theWorld != null && Bind.MENU.isPressed()) { - if(this.open != null) - this.displayGuiScreen(null); - else - this.displayGuiScreen(GuiMenu.INSTANCE); - } - else if(this.theWorld == null && !(this.open instanceof GuiMenu) && Bind.MENU.isPressed()) { - this.displayGuiScreen(GuiMenu.INSTANCE); - } - if(this.theWorld != null && Bind.INVENTORY.isPressed()) { - if(this.open instanceof GuiContainer) { - this.displayGuiScreen(null); + if(!(this.open instanceof GuiLoading)) { + if(!(this.open instanceof GuiConsole) && Bind.COMMAND.isPressed()) { + this.displayGuiScreen(GuiConsole.INSTANCE); } - else if(this.open == null) { - if(this.thePlayer.isRiding() && this.thePlayer.vehicle instanceof EntityHorse) - this.thePlayer.sendHorseInventory(); - else - this.displayGuiScreen(/* this.itemCheat ? new GuiCheat() : */ new GuiInventory(this.thePlayer)); + // if(this.theWorld != null && this.open == null && Bind.COMMAND.isPressed()) { + // this.displayGuiScreen(GuiChat.INSTANCE); + // } + if(this.theWorld != null && Bind.MENU.isPressed()) { + if(this.open != null) + this.displayGuiScreen(null); + else + this.displayGuiScreen(GuiMenu.INSTANCE); + } + else if(this.theWorld == null && !(this.open instanceof GuiMenu) && Bind.MENU.isPressed()) { + this.displayGuiScreen(GuiMenu.INSTANCE); + } + if(this.theWorld != null && Bind.INVENTORY.isPressed()) { + if(this.open instanceof GuiContainer) { + this.displayGuiScreen(null); + } + else if(this.open == null) { + if(this.thePlayer.isRiding() && this.thePlayer.vehicle instanceof EntityHorse) + this.thePlayer.sendHorseInventory(); + else + this.displayGuiScreen(/* this.itemCheat ? new GuiCheat() : */ new GuiInventory(this.thePlayer)); + } } } if(Bind.SHOW.isPressed()) { @@ -2328,19 +2333,11 @@ public class Game implements IThreadListener { return ((double)rtime()) / 1000000.0; } - public void convert(File folder, String user) { - Converter.convertMapFormat(folder, user); - } - public void bind(int port) { if(server != null) server.bind(port); } - public String getldebug() { - return this.getLeft(server); - } - public void distance(int distance) { if(this.renderGlobal != null) this.renderGlobal.setDisplayListEntitiesDirty(); @@ -2531,7 +2528,8 @@ public class Game implements IThreadListener { DebugFunction func = this.debug.get(key); if(func != null) { Bind.disableInput(key); - func.runner.execute(key); + if(!(this.open instanceof GuiLoading)) + func.runner.execute(key); } return func != null; } diff --git a/java/src/game/gui/Gui.java b/java/src/game/gui/Gui.java index 9be5967..b657286 100644 --- a/java/src/game/gui/Gui.java +++ b/java/src/game/gui/Gui.java @@ -317,31 +317,9 @@ public abstract class Gui { Drawing.drawGradient(0, 0, this.gm.fb_x, this.gm.fb_y, 0xc0101010, 0xd0101010); } else { - this.drawDirtBackground(0, 0, this.gm.fb_x, this.gm.fb_y); + Drawing.drawScaledBackground(this.gm, DIRT_BACKGROUND); } } - - public void drawDirtBackground(double x, double y, double width, double height) { - GlState.enableTexture2D(); - GlState.disableLighting(); - GlState.disableFog(); - RenderBuffer buf = Tessellator.getBuffer(); - this.gm.getTextureManager().bindTexture(DIRT_BACKGROUND); - GlState.color(1.0F, 1.0F, 1.0F, 1.0F); - double scale = 32.0; - buf.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR); - buf.pos(x, y + height, 0.0D).tex(0.0D, height / scale) - .color(64, 64, 64, 255).endVertex(); - buf.pos(x + width, y + height, 0.0D) - .tex(width / scale, height / scale) - .color(64, 64, 64, 255).endVertex(); - buf.pos(x + width, y, 0.0D).tex(width / scale, 0.0) - .color(64, 64, 64, 255).endVertex(); - buf.pos(x, y, 0.0D).tex(0.0D, 0.0) - .color(64, 64, 64, 255).endVertex(); - Tessellator.draw(); - GlState.disableTexture2D(); - } public void render() { this.drawMainBackground(); diff --git a/java/src/game/gui/world/GuiEdit.java b/java/src/game/gui/world/GuiEdit.java index 0212d3d..e04511f 100755 --- a/java/src/game/gui/world/GuiEdit.java +++ b/java/src/game/gui/world/GuiEdit.java @@ -75,7 +75,7 @@ public class GuiEdit extends Gui implements ActButton.Callback, Textbox.Callback public void init(int width, int height) { this.actionButton = this.add(new ActButton(width / 2 - 100, height / 4 + 96 + 12, 200, 20, (ActButton.Callback)this, this.action)); this.cancelButton = this.add(new ActButton(width / 2 - 100, height / 4 + 120 + 12, 200, 20, (ActButton.Callback)this, "Abbrechen")); - this.nameField = this.add(new Textbox(width / 2 - 100, 60, 200, 20, this.player ? NetHandlerPlayServer.MAX_USER_LENGTH : 256, true, this, this.player ? NetHandlerPlayServer.VALID_USER : GuiWorlds.VALID_FILE, this.original == null ? "" : this.original)); + this.nameField = this.add(new Textbox(width / 2 - 200, 60, 400, 20, this.player ? NetHandlerPlayServer.MAX_USER_LENGTH : 256, true, this, this.player ? NetHandlerPlayServer.VALID_USER : GuiWorlds.VALID_FILE, this.original == null ? "" : this.original)); this.nameField.setSelected(); // if(this.player) { // this.nameField.setMaxStringLength(16); @@ -96,7 +96,7 @@ public class GuiEdit extends Gui implements ActButton.Callback, Textbox.Callback // } // }); // } - this.actionLabel = this.add(new Label(width / 2 - 100, 20, 200, 24, this.getLabelDesc())); + this.actionLabel = this.add(new Label(width / 2 - 250, 20, 500, 24, this.getLabelDesc())); // this.shift(); // this.nameField.setText(); this.actionButton.enabled = false; diff --git a/java/src/game/gui/world/GuiWorlds.java b/java/src/game/gui/world/GuiWorlds.java index cda73b1..5b5b6b6 100755 --- a/java/src/game/gui/world/GuiWorlds.java +++ b/java/src/game/gui/world/GuiWorlds.java @@ -12,6 +12,7 @@ import java.util.Set; import com.google.common.collect.Sets; +import game.Game; import game.color.TextColor; import game.dimension.Dimension; import game.gui.GuiConfirm; @@ -487,8 +488,8 @@ public class GuiWorlds extends GuiList implements ActButton. } else { if(this.getSelected().mustConvert()) { - this.gm.convert(folder, user); - this.gm.displayGuiScreen(this); + Game r = this.gm; + Converter.convertMapFormat(folder, user); this.starting = false; } else { @@ -607,9 +608,10 @@ public class GuiWorlds extends GuiList implements ActButton. { super.drawOverlays(); if(this.warningMessage != null) { - drawRect(this.gm.fb_x / 2 - 191, this.gm.fb_y - 82, this.gm.fb_x / 2 + 191, this.gm.fb_y - 66, 0xff808080); - drawRect(this.gm.fb_x / 2 - 190, this.gm.fb_y - 81, this.gm.fb_x / 2 + 190, this.gm.fb_y - 67, 0xff000000); - Drawing.drawText(this.warningMessage, this.gm.fb_x / 2, this.gm.fb_y - 78, 0xffff0000); + Drawing.drawRectBorder(this.gm.fb_x / 2 - 200, this.gm.fb_y - 84, 400, 18, 0xff000000, 0xff808080); +// drawRect(this.gm.fb_x / 2 - 191, this.gm.fb_y - 82, this.gm.fb_x / 2 + 191, this.gm.fb_y - 66, 0xff808080); +// drawRect(this.gm.fb_x / 2 - 190, this.gm.fb_y - 81, this.gm.fb_x / 2 + 190, this.gm.fb_y - 67, 0xff000000); + Drawing.drawTextCentered(this.warningMessage, this.gm.fb_x / 2, this.gm.fb_y - 84, 0xffff0000); } } diff --git a/java/src/game/renderer/Drawing.java b/java/src/game/renderer/Drawing.java index 8c87bc0..59d7336 100644 --- a/java/src/game/renderer/Drawing.java +++ b/java/src/game/renderer/Drawing.java @@ -1,5 +1,6 @@ package game.renderer; +import game.Game; import game.color.TextColor; import game.gui.Font; import game.gui.FontChar; @@ -531,6 +532,11 @@ public abstract class Drawing { txt_draw(x, y, x, y, Integer.MAX_VALUE, Integer.MAX_VALUE, color, str); } + public static void drawTextCentered(String str, int x, int y, int color) { + Vec2i size = getSize(str); + drawText(str, x - size.xpos / 2, y, color); + } + public static void drawTextRight(String str, int x, int y, int color) { Vec2i size = getSize(str); drawText(str, x - size.xpos, y, color); @@ -545,4 +551,30 @@ public abstract class Drawing { return ((((c1 >> 24 & 255) + (c2 >> 24 & 255)) / 2) << 24) | ((((c1 >> 16 & 255) + (c2 >> 16 & 255)) / 2) << 16) | ((((c1 >> 8 & 255) + (c2 >> 8 & 255)) / 2) << 8) | (((c1 & 255) + (c2 & 255)) / 2); } + + public static void drawScaledBackground(Game gm, String texture) { + drawScaledBackground(gm, texture, 0, 0, gm.fb_x, gm.fb_y); + } + + public static void drawScaledBackground(Game gm, String texture, double x, double y, double width, double height) { + GlState.enableTexture2D(); + GlState.disableLighting(); + GlState.disableFog(); + RenderBuffer buf = Tessellator.getBuffer(); + gm.getTextureManager().bindTexture(texture); + GlState.color(1.0F, 1.0F, 1.0F, 1.0F); + double scale = 32.0; + buf.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR); + buf.pos(x, y + height, 0.0D).tex(0.0D, height / scale) + .color(64, 64, 64, 255).endVertex(); + buf.pos(x + width, y + height, 0.0D) + .tex(width / scale, height / scale) + .color(64, 64, 64, 255).endVertex(); + buf.pos(x + width, y, 0.0D).tex(width / scale, 0.0) + .color(64, 64, 64, 255).endVertex(); + buf.pos(x, y, 0.0D).tex(0.0D, 0.0) + .color(64, 64, 64, 255).endVertex(); + Tessellator.draw(); + GlState.disableTexture2D(); + } } diff --git a/java/src/game/world/Converter.java b/java/src/game/world/Converter.java index b955d75..739c7bc 100755 --- a/java/src/game/world/Converter.java +++ b/java/src/game/world/Converter.java @@ -15,6 +15,7 @@ import java.util.zip.InflaterInputStream; import com.google.common.collect.Maps; +import game.Game; import game.biome.Biome; import game.block.Block; import game.block.BlockCactus; @@ -57,6 +58,9 @@ import game.entity.animal.EntityWolf; import game.entity.item.EntityBoat; import game.entity.item.EntityMinecart; import game.entity.npc.EntityHuman; +import game.gui.GuiLoading; +import game.gui.GuiLoading.Callback; +import game.gui.world.GuiWorlds; import game.init.BlockRegistry; import game.init.Blocks; import game.init.Config; @@ -86,7 +90,7 @@ import game.tileentity.TileEntitySign; import game.tileentity.TileEntitySkull; import game.world.Region.FolderInfo; -public abstract class Converter { +public final class Converter { public static enum SaveVersion { ALPHA_1_0("Alpha 1.0 - Beta 1.2"), BETA_1_3("Beta 1.3 - Release 1.8.9"), @@ -189,8 +193,11 @@ public abstract class Converter { private static interface BlockFunction { State getState(int id, int data); } + + private Converter() { + } - private static long postProgress(long start, int progress) { + private long postProgress(long start, int progress) { // SKC.info("... " + progress + "%"); if(System.currentTimeMillis() - start >= 500L) { start = System.currentTimeMillis(); @@ -205,6 +212,14 @@ public abstract class Converter { private static final char[] BLOCK_MAP = new char[65536]; // private static final Map BLOCK_FUNCS = Maps.newHashMap(); private static final Map OLD_GAMERULES = Maps.newHashMap(); + + private String action; + private String task; + private String file; + private int totalRegions; + private int doneRegions; + private int totalChunks; + private int doneChunks; private static void mapEntity(Class clazz, String ... names) { String name = EntityRegistry.getEntityString(clazz); @@ -1110,13 +1125,17 @@ public abstract class Converter { return tag; } - private static long convertChunks(File dir, File file, long start, int progress, int total) { + private long convertChunks(File dir, File file, long start, int progress, int total) { String name = file.getName(); + this.file = name; + this.totalChunks = 1024; boolean legacy = name.endsWith(".mcr"); int rx, rz; String[] reg = name.split("\\."); if(reg.length != 4) { Log.JNI.warn("Unbekannte Region " + file); + this.doneChunks = 0; + this.file = null; return start; } try { @@ -1125,6 +1144,8 @@ public abstract class Converter { } catch(NumberFormatException e) { Log.JNI.warn("Unbekannte Region " + file); + this.doneChunks = 0; + this.file = null; return start; } try { @@ -1136,8 +1157,10 @@ public abstract class Converter { Region newreg; for(int bx = 0; bx < 4; bx++) { for(int bz = 0; bz < 4; bz++) { - if(!oldreg.hasRegion(bx, bz)) + if(!oldreg.hasRegion(bx, bz)) { + this.doneChunks += 64; continue; + } areas++; newreg = new Region(dir, rx * 4 + bx, rz * 4 + bz); Log.JNI.info("Konvertiere " + file + " zu " + newreg.getFile() + " ..."); @@ -1150,6 +1173,7 @@ public abstract class Converter { DataInputStream in = oldreg.getInputStream(x, z); if(in == null) { Log.JNI.warn("Konnte " + file.getPath() + "@" + x + "," + z + " nicht lesen"); + this.doneChunks += 1; continue; } NBTTagCompound tag = NBTLoader.read(in); @@ -1160,6 +1184,7 @@ public abstract class Converter { // out.close(); newreg.writeTag(nx, nz, tag); } + this.doneChunks += 1; } } newreg.close(false); @@ -1168,6 +1193,7 @@ public abstract class Converter { if(percent > prev) { start = postProgress(start, percent); } +// this.doneChunks += 1; } } oldreg.close(); @@ -1176,6 +1202,8 @@ public abstract class Converter { catch(IOException e) { e.printStackTrace(); } + this.doneChunks = 0; + this.file = null; return start; } @@ -1222,122 +1250,161 @@ public abstract class Converter { // NBTTagCompound nbt = getLegacyWorldInfo(dir); // if(nbt == null) // return false; - Log.IO.info("Version: %s", ver); - if(ver != SaveVersion.RELEASE_1_13) { - Log.JNI.info("Konvertiere Chunk-Daten von region/*.mca,*.mcr"); - File regionDir = new File(dir, "region"); - if(regionDir.exists()) { - File chunkDir = new File(new File(dir, "chunk"), "terra"); - Log.JNI.info("Konvertiere Welt nach '" + chunkDir + "' ..."); - Log.JNI.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.JNI.info("Keine .mca- oder .mcr-Dateien gefunden."); + final Converter conv = new Converter(); + Game.getGame().displayGuiScreen(new GuiLoading("Konvertiere Welt ...", new Callback() { + public void poll(Game gm, GuiLoading gui) { + if(conv.totalRegions > 0) { + gui.setBar(conv.task, "Regionen", conv.totalRegions); + gui.setProgress(conv.doneRegions); } else { - Log.JNI.info("Ingesamt wurden " + files.length + " .mca-Dateien und .mcr-Dateien gefunden, konvertiere ..."); - if(ver == SaveVersion.RELEASE_1_9) - Log.JNI.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) { - start = convertChunks(chunkDir, file, start, progress, files.length); - ++progress; - int percent = (int)Math.round(100.0D * (double)progress / (double)files.length); - Log.JNI.info("Konvertiere Chunk-Daten: " + file.getName() + " (" + progress + "/" + files.length + ")"); - start = postProgress(start, percent); - } - time = System.currentTimeMillis() - time; - Log.JNI.info("Fertig. Konversion dauerte " + ((time / 60000L) > 0 ? ((time / 60000L) + " Minuten und ") : "") + ((time / 1000L) % 60L) + " Sekunden."); + gui.resetBar(); } + if(conv.totalChunks > 0) { + gui.setSub(conv.file, "Chunks", conv.totalChunks); + gui.setSubProgress(conv.doneChunks); + } + else { + gui.resetSub(); + } + gui.setTask(conv.action == null ? "" : conv.action); } - } - else { - Log.JNI.warn("Konvertiere keine Chunk-Daten, da Version zu neu"); - } - Log.JNI.info("Konvertiere Daten von level.dat"); - Config.clear(); - UniverseRegistry.clear(); - if(nbt.hasKey("GameRules", 10)) { - NBTTagCompound rules = nbt.getCompoundTag("GameRules"); - for(Entry rule : OLD_GAMERULES.entrySet()) { - if(rules.hasKey(rule.getKey(), 8)) - Config.set(rule.getValue(), rules.getString(rule.getKey()), null); + })); + final NBTTagCompound tag = nbt; + new Thread(new Runnable() { + public void run() { + Log.IO.info("Version: %s", ver); + if(ver != SaveVersion.RELEASE_1_13) { + conv.action = "Suche nach Chunk-Daten"; + Log.JNI.info("Konvertiere Chunk-Daten von region/*.mca,*.mcr"); + File regionDir = new File(dir, "region"); + if(regionDir.exists()) { + File chunkDir = new File(new File(dir, "chunk"), "terra"); + Log.JNI.info("Konvertiere Welt nach '" + chunkDir + "' ..."); + Log.JNI.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.JNI.info("Keine .mca- oder .mcr-Dateien gefunden."); + } + else { + conv.task = "Konvertiere Chunkdaten"; + conv.totalRegions = files.length; + Log.JNI.info("Ingesamt wurden " + files.length + " .mca-Dateien und .mcr-Dateien gefunden, konvertiere ..."); + if(ver == SaveVersion.RELEASE_1_9) + Log.JNI.info("Konvertiere von neuerer Version, dies wird Blöcke entfernen ..."); + chunkDir.mkdirs(); + int progress = 0; + long time = System.currentTimeMillis(); + long start = conv.postProgress(time, 0); + for(File file : files) { + int percent = (int)Math.round(100.0D * (double)progress / (double)files.length); + Log.JNI.info("Konvertiere Chunk-Daten: " + file.getName() + " (" + progress + "/" + files.length + ")"); + start = conv.convertChunks(chunkDir, file, start, progress, files.length); + ++progress; + start = conv.postProgress(start, percent); + conv.doneRegions += 1; + } + time = System.currentTimeMillis() - time; + Log.JNI.info("Fertig. Konversion dauerte " + ((time / 60000L) > 0 ? ((time / 60000L) + " Minuten und ") : "") + ((time / 1000L) % 60L) + " Sekunden."); + } + } + } + else { + Log.JNI.warn("Konvertiere keine Chunk-Daten, da Version zu neu"); + } + conv.doneRegions = 0; + conv.task = null; + conv.action = "Konvertiere level.dat"; + Log.JNI.info("Konvertiere Daten von level.dat"); + Config.clear(); + UniverseRegistry.clear(); + if(tag.hasKey("GameRules", 10)) { + NBTTagCompound rules = tag.getCompoundTag("GameRules"); + for(Entry rule : OLD_GAMERULES.entrySet()) { + if(rules.hasKey(rule.getKey(), 8)) + Config.set(rule.getValue(), rules.getString(rule.getKey()), null); + } + } + // Config.setVar("noRespawn", "" + nbt.getBoolean("hardcore"), false); + // int id = nbt.getInteger("GameType"); + // Config.set("defaultNoCreative", "" + (id == 2 || id == 0), false); + Config.set("spawnX", "" + tag.getInteger("SpawnX"), null); + Config.set("spawnY", "" + tag.getInteger("SpawnY"), null); + Config.set("spawnZ", "" + tag.getInteger("SpawnZ"), null); + Config.set("spawnDim", "" + 1, null); + Log.JNI.info("Speichere neue level.nbt ..."); + Region.saveWorldInfo(dir, wtime, user); + if(tag.hasKey("Player", 10)) { + conv.action = "Konvertiere Spielerdaten"; + NBTTagCompound player = tag.getCompoundTag("Player"); + NBTTagList pos = player.getTagList("Pos", 6); + NBTTagList motion = player.getTagList("Motion", 6); + NBTTagList rotation = player.getTagList("Rotation", 5); + boolean ground = player.getBoolean("OnGround"); + BlockPos spawn = null; + // boolean force = player.getBoolean("OnGround"); + // int mode = -1; + // if(player.hasKey("playerGameType", 99)) { + // mode = player.getInteger("playerGameType"); + // mode = mode == 0 || mode == 2 ? 0 : (mode == 1 || mode == 3 ? 1 : -1); + // } + if(player.hasKey("SpawnX", 99) && player.hasKey("SpawnY", 99) && player.hasKey("SpawnZ", 99)) { + spawn = new BlockPos(player.getInteger("SpawnX"), player.getInteger("SpawnY"), + player.getInteger("SpawnZ")); + // force = player.getBoolean("SpawnForced"); + } + player.getKeySet().clear(); + player.setTag("Pos", pos); + player.setTag("Motion", motion); + player.setTag("Rotation", rotation); + player.setBoolean("OnGround", ground); + player.setInteger("Dimension", 1); + player.setString("id", EntityRegistry.getEntityString(EntityHuman.class)); + if(spawn != null) { + player.setInteger("SpawnX", spawn.getX()); + player.setInteger("SpawnY", spawn.getY()); + player.setInteger("SpawnZ", spawn.getZ()); + player.setInteger("SpawnDim", 1); + // player.setBoolean("SpawnForced", force); + } + // if(mode >= 0) + // player.setBoolean("creative", mode == 1); + Log.JNI.info("Speichere neue Spielerdaten " + user.toLowerCase() + ".nbt ..."); + File pdat = new File(new File(dir, "players"), user.toLowerCase() + ".nbt"); + try { + pdat.getParentFile().mkdirs(); + NBTLoader.writeGZip(player, pdat); + } + catch(Exception e) { + Log.JNI.error(e, "Fehler beim Schreiben von " + pdat); + } + } + Weather weather = tag.getBoolean("thundering") ? Weather.THUNDER : (tag.getBoolean("raining") ? Weather.RAIN : Weather.CLEAR); + if(weather != Weather.CLEAR) { + conv.action = "Konvertiere Dimensionsdaten"; + NBTTagCompound dataTag = new NBTTagCompound(); + dataTag.setString("Weather", weather.getName()); + Log.JNI.info("Speichere neue data.nbt ..."); + File dataFile = new File(new File(new File(dir, "chunk"), "terra"), "data.nbt"); + try { + NBTLoader.writeGZip(dataTag, dataFile); + } + catch(Exception e) { + Log.JNI.error(e, "Konnte Weltdaten nicht speichern"); + } + } + Log.IO.info("Welt '" + dir + "' wurde in %d Sekunden konvertiert", (System.currentTimeMillis() - cur) / 1000L); + Game.getGame().schedule(new Runnable() { + public void run() { + Game.getGame().displayGuiScreen(GuiWorlds.INSTANCE); + } + }); } - } -// Config.setVar("noRespawn", "" + nbt.getBoolean("hardcore"), false); -// int id = nbt.getInteger("GameType"); -// Config.set("defaultNoCreative", "" + (id == 2 || id == 0), false); - Config.set("spawnX", "" + nbt.getInteger("SpawnX"), null); - Config.set("spawnY", "" + nbt.getInteger("SpawnY"), null); - Config.set("spawnZ", "" + nbt.getInteger("SpawnZ"), null); - Config.set("spawnDim", "" + 1, null); - Log.JNI.info("Speichere neue level.nbt ..."); - Region.saveWorldInfo(dir, wtime, user); - if(nbt.hasKey("Player", 10)) { - NBTTagCompound player = nbt.getCompoundTag("Player"); - NBTTagList pos = player.getTagList("Pos", 6); - NBTTagList motion = player.getTagList("Motion", 6); - NBTTagList rotation = player.getTagList("Rotation", 5); - boolean ground = player.getBoolean("OnGround"); - BlockPos spawn = null; -// boolean force = player.getBoolean("OnGround"); -// int mode = -1; -// if(player.hasKey("playerGameType", 99)) { -// mode = player.getInteger("playerGameType"); -// mode = mode == 0 || mode == 2 ? 0 : (mode == 1 || mode == 3 ? 1 : -1); -// } - if(player.hasKey("SpawnX", 99) && player.hasKey("SpawnY", 99) && player.hasKey("SpawnZ", 99)) { - spawn = new BlockPos(player.getInteger("SpawnX"), player.getInteger("SpawnY"), - player.getInteger("SpawnZ")); -// force = player.getBoolean("SpawnForced"); - } - player.getKeySet().clear(); - player.setTag("Pos", pos); - player.setTag("Motion", motion); - player.setTag("Rotation", rotation); - player.setBoolean("OnGround", ground); - player.setInteger("Dimension", 1); - player.setString("id", EntityRegistry.getEntityString(EntityHuman.class)); - if(spawn != null) { - player.setInteger("SpawnX", spawn.getX()); - player.setInteger("SpawnY", spawn.getY()); - player.setInteger("SpawnZ", spawn.getZ()); - player.setInteger("SpawnDim", 1); -// player.setBoolean("SpawnForced", force); - } -// if(mode >= 0) -// player.setBoolean("creative", mode == 1); - Log.JNI.info("Speichere neue Spielerdaten " + user.toLowerCase() + ".nbt ..."); - File pdat = new File(new File(dir, "players"), user.toLowerCase() + ".nbt"); - try { - pdat.getParentFile().mkdirs(); - NBTLoader.writeGZip(player, pdat); - } - catch(Exception e) { - Log.JNI.error(e, "Fehler beim Schreiben von " + pdat); - } - } - Weather weather = nbt.getBoolean("thundering") ? Weather.THUNDER : (nbt.getBoolean("raining") ? Weather.RAIN : Weather.CLEAR); - if(weather != Weather.CLEAR) { - NBTTagCompound dataTag = new NBTTagCompound(); - dataTag.setString("Weather", weather.getName()); - Log.JNI.info("Speichere neue data.nbt ..."); - File dataFile = new File(new File(new File(dir, "chunk"), "terra"), "data.nbt"); - try { - NBTLoader.writeGZip(dataTag, dataFile); - } - catch(Exception e) { - Log.JNI.error(e, "Konnte Weltdaten nicht speichern"); - } - } - Log.IO.info("Welt '" + dir + "' wurde in %d Sekunden konvertiert", (System.currentTimeMillis() - cur) / 1000L); + }, "Converter Thread").start(); return new FolderInfo(wtime, user, System.currentTimeMillis(), null, Config.VERSION); } diff --git a/java/src/game/world/WorldClient.java b/java/src/game/world/WorldClient.java index 5c9c4f4..2088246 100755 --- a/java/src/game/world/WorldClient.java +++ b/java/src/game/world/WorldClient.java @@ -921,4 +921,8 @@ public class WorldClient extends World public String getDebugLoadedEntities() { return "" + this.entities.size(); } + + public boolean hasNoChunks() { + return this.chunkListing.isEmpty(); + } }