loading gui + converter

This commit is contained in:
Sen 2025-03-16 21:58:40 +01:00
parent 9df6406a93
commit 90de256e04
7 changed files with 259 additions and 178 deletions

View file

@ -63,6 +63,7 @@ import game.gui.Gui;
import game.gui.GuiConsole; import game.gui.GuiConsole;
import game.gui.GuiGameOver; import game.gui.GuiGameOver;
import game.gui.GuiInfo; import game.gui.GuiInfo;
import game.gui.GuiLoading;
import game.gui.GuiMenu; import game.gui.GuiMenu;
import game.gui.Style; import game.gui.Style;
import game.gui.container.GuiContainer; import game.gui.container.GuiContainer;
@ -933,6 +934,8 @@ public class Game implements IThreadListener {
} }
if(this.open != null) if(this.open != null)
this.open.render(); 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))) if(Bind.INFO.isDown() && (this.open == null || !(this.open.selected instanceof Textbox)))
this.drawInfo(); this.drawInfo();
if(this.hudOverlay && !(this.open instanceof GuiConsole)) if(this.hudOverlay && !(this.open instanceof GuiConsole))
@ -958,7 +961,7 @@ public class Game implements IThreadListener {
int y1 = 0; int y1 = 0;
int y2 = this.fb_y; int y2 = this.fb_y;
// int pos = 0; // int pos = 0;
String str = this.getldebug(); String str = this.getLeft(this.server);
// if(jstr) // if(jstr)
// str = (*jsys.env)->GetStringUTFChars(jsys.env, jstr, NULL); // str = (*jsys.env)->GetStringUTFChars(jsys.env, jstr, NULL);
// elem->r_dirty = 1; // elem->r_dirty = 1;
@ -2118,30 +2121,32 @@ public class Game implements IThreadListener {
if(Bind.FULLSCREEN.isPressed()) { if(Bind.FULLSCREEN.isPressed()) {
this.full(!this.fullscreen); this.full(!this.fullscreen);
} }
if(!(this.open instanceof GuiConsole) && Bind.COMMAND.isPressed()) { if(!(this.open instanceof GuiLoading)) {
this.displayGuiScreen(GuiConsole.INSTANCE); 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);
} }
else if(this.open == null) { // if(this.theWorld != null && this.open == null && Bind.COMMAND.isPressed()) {
if(this.thePlayer.isRiding() && this.thePlayer.vehicle instanceof EntityHorse) // this.displayGuiScreen(GuiChat.INSTANCE);
this.thePlayer.sendHorseInventory(); // }
else if(this.theWorld != null && Bind.MENU.isPressed()) {
this.displayGuiScreen(/* this.itemCheat ? new GuiCheat() : */ new GuiInventory(this.thePlayer)); 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()) { if(Bind.SHOW.isPressed()) {
@ -2328,19 +2333,11 @@ public class Game implements IThreadListener {
return ((double)rtime()) / 1000000.0; return ((double)rtime()) / 1000000.0;
} }
public void convert(File folder, String user) {
Converter.convertMapFormat(folder, user);
}
public void bind(int port) { public void bind(int port) {
if(server != null) if(server != null)
server.bind(port); server.bind(port);
} }
public String getldebug() {
return this.getLeft(server);
}
public void distance(int distance) { public void distance(int distance) {
if(this.renderGlobal != null) if(this.renderGlobal != null)
this.renderGlobal.setDisplayListEntitiesDirty(); this.renderGlobal.setDisplayListEntitiesDirty();
@ -2531,7 +2528,8 @@ public class Game implements IThreadListener {
DebugFunction func = this.debug.get(key); DebugFunction func = this.debug.get(key);
if(func != null) { if(func != null) {
Bind.disableInput(key); Bind.disableInput(key);
func.runner.execute(key); if(!(this.open instanceof GuiLoading))
func.runner.execute(key);
} }
return func != null; return func != null;
} }

View file

@ -317,31 +317,9 @@ public abstract class Gui {
Drawing.drawGradient(0, 0, this.gm.fb_x, this.gm.fb_y, 0xc0101010, 0xd0101010); Drawing.drawGradient(0, 0, this.gm.fb_x, this.gm.fb_y, 0xc0101010, 0xd0101010);
} }
else { 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() { public void render() {
this.drawMainBackground(); this.drawMainBackground();

View file

@ -75,7 +75,7 @@ public class GuiEdit extends Gui implements ActButton.Callback, Textbox.Callback
public void init(int width, int height) { 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.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.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(); this.nameField.setSelected();
// if(this.player) { // if(this.player) {
// this.nameField.setMaxStringLength(16); // 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.shift();
// this.nameField.setText(); // this.nameField.setText();
this.actionButton.enabled = false; this.actionButton.enabled = false;

View file

@ -12,6 +12,7 @@ import java.util.Set;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import game.Game;
import game.color.TextColor; import game.color.TextColor;
import game.dimension.Dimension; import game.dimension.Dimension;
import game.gui.GuiConfirm; import game.gui.GuiConfirm;
@ -487,8 +488,8 @@ public class GuiWorlds extends GuiList<GuiWorlds.SaveInfo> implements ActButton.
} }
else { else {
if(this.getSelected().mustConvert()) { if(this.getSelected().mustConvert()) {
this.gm.convert(folder, user); Game r = this.gm;
this.gm.displayGuiScreen(this); Converter.convertMapFormat(folder, user);
this.starting = false; this.starting = false;
} }
else { else {
@ -607,9 +608,10 @@ public class GuiWorlds extends GuiList<GuiWorlds.SaveInfo> implements ActButton.
{ {
super.drawOverlays(); super.drawOverlays();
if(this.warningMessage != null) { 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); Drawing.drawRectBorder(this.gm.fb_x / 2 - 200, this.gm.fb_y - 84, 400, 18, 0xff000000, 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); // drawRect(this.gm.fb_x / 2 - 191, this.gm.fb_y - 82, this.gm.fb_x / 2 + 191, this.gm.fb_y - 66, 0xff808080);
Drawing.drawText(this.warningMessage, this.gm.fb_x / 2, this.gm.fb_y - 78, 0xffff0000); // 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);
} }
} }

View file

@ -1,5 +1,6 @@
package game.renderer; package game.renderer;
import game.Game;
import game.color.TextColor; import game.color.TextColor;
import game.gui.Font; import game.gui.Font;
import game.gui.FontChar; 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); 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) { public static void drawTextRight(String str, int x, int y, int color) {
Vec2i size = getSize(str); Vec2i size = getSize(str);
drawText(str, x - size.xpos, y, color); 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) | 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); (((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();
}
} }

View file

@ -15,6 +15,7 @@ import java.util.zip.InflaterInputStream;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import game.Game;
import game.biome.Biome; import game.biome.Biome;
import game.block.Block; import game.block.Block;
import game.block.BlockCactus; import game.block.BlockCactus;
@ -57,6 +58,9 @@ import game.entity.animal.EntityWolf;
import game.entity.item.EntityBoat; import game.entity.item.EntityBoat;
import game.entity.item.EntityMinecart; import game.entity.item.EntityMinecart;
import game.entity.npc.EntityHuman; 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.BlockRegistry;
import game.init.Blocks; import game.init.Blocks;
import game.init.Config; import game.init.Config;
@ -86,7 +90,7 @@ import game.tileentity.TileEntitySign;
import game.tileentity.TileEntitySkull; import game.tileentity.TileEntitySkull;
import game.world.Region.FolderInfo; import game.world.Region.FolderInfo;
public abstract class Converter { public final class Converter {
public static enum SaveVersion { public static enum SaveVersion {
ALPHA_1_0("Alpha 1.0 - Beta 1.2"), ALPHA_1_0("Alpha 1.0 - Beta 1.2"),
BETA_1_3("Beta 1.3 - Release 1.8.9"), BETA_1_3("Beta 1.3 - Release 1.8.9"),
@ -189,8 +193,11 @@ public abstract class Converter {
private static interface BlockFunction { private static interface BlockFunction {
State getState(int id, int data); 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 + "%"); // SKC.info("... " + progress + "%");
if(System.currentTimeMillis() - start >= 500L) { if(System.currentTimeMillis() - start >= 500L) {
start = System.currentTimeMillis(); start = System.currentTimeMillis();
@ -205,6 +212,14 @@ public abstract class Converter {
private static final char[] BLOCK_MAP = new char[65536]; private static final char[] BLOCK_MAP = new char[65536];
// private static final Map<Character, BlockFunction> BLOCK_FUNCS = Maps.newHashMap(); // private static final Map<Character, BlockFunction> BLOCK_FUNCS = Maps.newHashMap();
private static final Map<String, String> OLD_GAMERULES = Maps.newHashMap(); private static final Map<String, String> 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<? extends Entity> clazz, String ... names) { private static void mapEntity(Class<? extends Entity> clazz, String ... names) {
String name = EntityRegistry.getEntityString(clazz); String name = EntityRegistry.getEntityString(clazz);
@ -1110,13 +1125,17 @@ public abstract class Converter {
return tag; 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(); String name = file.getName();
this.file = name;
this.totalChunks = 1024;
boolean legacy = name.endsWith(".mcr"); boolean legacy = name.endsWith(".mcr");
int rx, rz; int rx, rz;
String[] reg = name.split("\\."); String[] reg = name.split("\\.");
if(reg.length != 4) { if(reg.length != 4) {
Log.JNI.warn("Unbekannte Region " + file); Log.JNI.warn("Unbekannte Region " + file);
this.doneChunks = 0;
this.file = null;
return start; return start;
} }
try { try {
@ -1125,6 +1144,8 @@ public abstract class Converter {
} }
catch(NumberFormatException e) { catch(NumberFormatException e) {
Log.JNI.warn("Unbekannte Region " + file); Log.JNI.warn("Unbekannte Region " + file);
this.doneChunks = 0;
this.file = null;
return start; return start;
} }
try { try {
@ -1136,8 +1157,10 @@ public abstract class Converter {
Region newreg; Region newreg;
for(int bx = 0; bx < 4; bx++) { for(int bx = 0; bx < 4; bx++) {
for(int bz = 0; bz < 4; bz++) { for(int bz = 0; bz < 4; bz++) {
if(!oldreg.hasRegion(bx, bz)) if(!oldreg.hasRegion(bx, bz)) {
this.doneChunks += 64;
continue; continue;
}
areas++; areas++;
newreg = new Region(dir, rx * 4 + bx, rz * 4 + bz); newreg = new Region(dir, rx * 4 + bx, rz * 4 + bz);
Log.JNI.info("Konvertiere " + file + " zu " + newreg.getFile() + " ..."); Log.JNI.info("Konvertiere " + file + " zu " + newreg.getFile() + " ...");
@ -1150,6 +1173,7 @@ public abstract class Converter {
DataInputStream in = oldreg.getInputStream(x, z); DataInputStream in = oldreg.getInputStream(x, z);
if(in == null) { if(in == null) {
Log.JNI.warn("Konnte " + file.getPath() + "@" + x + "," + z + " nicht lesen"); Log.JNI.warn("Konnte " + file.getPath() + "@" + x + "," + z + " nicht lesen");
this.doneChunks += 1;
continue; continue;
} }
NBTTagCompound tag = NBTLoader.read(in); NBTTagCompound tag = NBTLoader.read(in);
@ -1160,6 +1184,7 @@ public abstract class Converter {
// out.close(); // out.close();
newreg.writeTag(nx, nz, tag); newreg.writeTag(nx, nz, tag);
} }
this.doneChunks += 1;
} }
} }
newreg.close(false); newreg.close(false);
@ -1168,6 +1193,7 @@ public abstract class Converter {
if(percent > prev) { if(percent > prev) {
start = postProgress(start, percent); start = postProgress(start, percent);
} }
// this.doneChunks += 1;
} }
} }
oldreg.close(); oldreg.close();
@ -1176,6 +1202,8 @@ public abstract class Converter {
catch(IOException e) { catch(IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
this.doneChunks = 0;
this.file = null;
return start; return start;
} }
@ -1222,122 +1250,161 @@ public abstract class Converter {
// NBTTagCompound nbt = getLegacyWorldInfo(dir); // NBTTagCompound nbt = getLegacyWorldInfo(dir);
// if(nbt == null) // if(nbt == null)
// return false; // return false;
Log.IO.info("Version: %s", ver); final Converter conv = new Converter();
if(ver != SaveVersion.RELEASE_1_13) { Game.getGame().displayGuiScreen(new GuiLoading("Konvertiere Welt ...", new Callback() {
Log.JNI.info("Konvertiere Chunk-Daten von region/*.mca,*.mcr"); public void poll(Game gm, GuiLoading gui) {
File regionDir = new File(dir, "region"); if(conv.totalRegions > 0) {
if(regionDir.exists()) { gui.setBar(conv.task, "Regionen", conv.totalRegions);
File chunkDir = new File(new File(dir, "chunk"), "terra"); gui.setProgress(conv.doneRegions);
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 { else {
Log.JNI.info("Ingesamt wurden " + files.length + " .mca-Dateien und .mcr-Dateien gefunden, konvertiere ..."); gui.resetBar();
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.");
} }
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 { final NBTTagCompound tag = nbt;
Log.JNI.warn("Konvertiere keine Chunk-Daten, da Version zu neu"); new Thread(new Runnable() {
} public void run() {
Log.JNI.info("Konvertiere Daten von level.dat"); Log.IO.info("Version: %s", ver);
Config.clear(); if(ver != SaveVersion.RELEASE_1_13) {
UniverseRegistry.clear(); conv.action = "Suche nach Chunk-Daten";
if(nbt.hasKey("GameRules", 10)) { Log.JNI.info("Konvertiere Chunk-Daten von region/*.mca,*.mcr");
NBTTagCompound rules = nbt.getCompoundTag("GameRules"); File regionDir = new File(dir, "region");
for(Entry<String, String> rule : OLD_GAMERULES.entrySet()) { if(regionDir.exists()) {
if(rules.hasKey(rule.getKey(), 8)) File chunkDir = new File(new File(dir, "chunk"), "terra");
Config.set(rule.getValue(), rules.getString(rule.getKey()), null); 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<String, String> 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);
}
});
} }
} }, "Converter Thread").start();
// 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);
return new FolderInfo(wtime, user, System.currentTimeMillis(), null, Config.VERSION); return new FolderInfo(wtime, user, System.currentTimeMillis(), null, Config.VERSION);
} }

View file

@ -921,4 +921,8 @@ public class WorldClient extends World
public String getDebugLoadedEntities() { public String getDebugLoadedEntities() {
return "" + this.entities.size(); return "" + this.entities.size();
} }
public boolean hasNoChunks() {
return this.chunkListing.isEmpty();
}
} }