From 374e0c4617149da13312df33af904b6f3887af12 Mon Sep 17 00:00:00 2001 From: Sen Date: Sat, 31 May 2025 16:46:48 +0200 Subject: [PATCH] remove server side debug --- client/src/main/java/client/Client.java | 25 +- .../src/main/java/client/gui/GuiConsole.java | 3 +- client/src/main/java/client/gui/GuiMenu.java | 5 + .../client/gui/character/GuiCharacters.java | 15 +- .../client/network/ClientLoginHandler.java | 1 - .../java/client/network/ClientPlayer.java | 633 ++++++++---------- .../java/client/network/DummyConnection.java | 67 ++ .../main/java/client/network/DummyPlayer.java | 321 +++++++++ .../java/client/renderer/BlockRenderer.java | 2 +- .../java/client/util/DummyController.java | 77 +++ .../java/client/util/PlayerController.java | 6 +- .../main/java/client/world/ChunkEmpty.java | 46 +- .../main/java/client/world/WorldClient.java | 5 +- .../common/packet/RPacketLoginSuccess.java | 12 - .../main/java/common/world/AWorldClient.java | 4 +- .../main/java/common/world/AWorldServer.java | 4 +- common/src/main/java/common/world/Chunk.java | 5 - .../main/java/common/world/DebugStates.java | 37 - common/src/main/java/common/world/World.java | 15 +- server/src/main/java/server/Server.java | 78 +-- .../main/java/server/world/WorldServer.java | 497 +++++++------- .../java/server/worldgen/GeneratorDebug.java | 27 - 22 files changed, 1084 insertions(+), 801 deletions(-) create mode 100644 client/src/main/java/client/network/DummyConnection.java create mode 100644 client/src/main/java/client/network/DummyPlayer.java create mode 100644 client/src/main/java/client/util/DummyController.java delete mode 100644 common/src/main/java/common/world/DebugStates.java delete mode 100755 server/src/main/java/server/worldgen/GeneratorDebug.java diff --git a/client/src/main/java/client/Client.java b/client/src/main/java/client/Client.java index 4768029..e2cd3ce 100755 --- a/client/src/main/java/client/Client.java +++ b/client/src/main/java/client/Client.java @@ -22,7 +22,6 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Queue; -import java.util.Set; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.Executors; @@ -111,6 +110,7 @@ import common.entity.Entity; import common.entity.animal.EntityHorse; import common.entity.npc.Energy; import common.entity.npc.EntityNPC; +import common.entity.npc.PlayerCharacter; import common.entity.types.EntityLiving; import common.future.Futures; import common.future.ListenableFuture; @@ -286,7 +286,9 @@ public class Client implements IThreadListener { private final List feed = Lists.newArrayList(); private final List hotbar = Lists.newArrayList(); private final File config = new File(System.getProperty("config.file", "client.cfg")); - + public final Map playerList = Maps.newTreeMap(); + public final List characterList = Lists.newArrayList(); + private boolean primary; private boolean secondary; private boolean tertiary; @@ -295,7 +297,7 @@ public class Client implements IThreadListener { public boolean jump; public boolean sneak; public boolean debugCamEnable; - public boolean debugWorld; + public boolean noResolve; public boolean zooming; public boolean sprint; public boolean renderOutlines; @@ -316,6 +318,7 @@ public class Client implements IThreadListener { public int thirdPersonView; public int timeFactor = 1; public int chunksUpdated; + public int selectedCharacter = -1; private long lastTicked = 0L; private long debugUpdateTime = System.currentTimeMillis(); @@ -578,7 +581,7 @@ public class Client implements IThreadListener { ClientPlayer netHandler = this.getNetHandler(); if(netHandler != null) netHandler.cleanup(); - this.debugWorld = false; + this.noResolve = false; this.charEditor = false; this.viewEntity = null; this.connection = null; @@ -586,6 +589,9 @@ public class Client implements IThreadListener { this.player = null; this.serverInfo = null; this.lastTickTime = -1; + this.selectedCharacter = -1; + this.playerList.clear(); + this.characterList.clear(); this.soundManager.stopSounds(); } @@ -1885,7 +1891,7 @@ public class Client implements IThreadListener { BlockPos pos = this.pointed.block; State block = this.world.getState(pos); - if(!this.debugWorld) { + if(!this.noResolve) { block = block.getBlock().getActualState(block, this.world, pos); } @@ -2472,7 +2478,7 @@ public class Client implements IThreadListener { public void unload(boolean loading) { if(this.world != null && this.getNetHandler() != null) - this.getNetHandler().getNetworkManager().closeChannel("Quitting"); + this.getNetHandler().getConnection().closeChannel("Quitting"); this.unloadWorld(); this.displayGuiScreen(GuiMenu.INSTANCE); } @@ -2701,7 +2707,7 @@ public class Client implements IThreadListener { this.registerDebug(Keysym.AE, "Programm sofort beenden und server beenden", new DebugRunner() { public void execute(Keysym key) { if(Client.this.getNetHandler() != null) { - Client.this.getNetHandler().getNetworkManager().sendPacket(new CPacketMessage(CPacketMessage.Type.COMMAND, "shutdown"), new GenericFutureListener>() { + Client.this.getNetHandler().getConnection().sendPacket(new CPacketMessage(CPacketMessage.Type.COMMAND, "shutdown"), new GenericFutureListener>() { public void operationComplete(Future u) throws Exception { try { Thread.sleep(1000L); @@ -3192,13 +3198,12 @@ public class Client implements IThreadListener { public void drawInfo() { ClientPlayer netHandler = this.getNetHandler(); if(netHandler != null) { - Set> list = netHandler.getPlayerList(); - int size = list.size(); + int size = this.playerList.size(); int w = size > 80 ? 4 : (size > 40 ? 3 : (size > 10 ? 2 : 1)); w = Math.min(w, Math.max(1, this.fb_x / 300)); int bx = 0; int by = 0; - for(Entry elem : list) { + for(Entry elem : this.playerList.entrySet()) { int x = this.fb_x / 2 - (w * 300) / 2 + bx * 300; int y = 10 + by * Font.YGLYPH; Drawing.drawGradient(x, y, 300, Font.YGLYPH, 0x7f404040, 0x7f000000); diff --git a/client/src/main/java/client/gui/GuiConsole.java b/client/src/main/java/client/gui/GuiConsole.java index d3c6aca..dc579fa 100644 --- a/client/src/main/java/client/gui/GuiConsole.java +++ b/client/src/main/java/client/gui/GuiConsole.java @@ -10,7 +10,6 @@ import client.gui.element.PressType; import client.gui.element.FieldAction; import client.gui.element.Field; import client.gui.element.FieldCallback; -import client.network.ClientPlayer; import client.vars.BoolVar; import client.vars.CVar; import client.gui.element.TransparentArea; @@ -218,7 +217,7 @@ public class GuiConsole extends Gui implements FieldCallback { s = argv[argv.length - 1]; Iterable res = pre.startsWith("#") ? (argv.length == 1 ? this.gm.getVars() : (argv.length == 2 ? getVarCompletion(argv[0].substring(1)) : Lists.newArrayList())) : - (this.gm.player == null ? Lists.newArrayList() : ((ClientPlayer)this.gm.player.client).getPlayerNames()); + (this.gm.player == null ? Lists.newArrayList() : this.gm.playerList.keySet()); if(argv.length == 1 && pre.startsWith("#")) s = s.substring(1); for(String s1 : res) { diff --git a/client/src/main/java/client/gui/GuiMenu.java b/client/src/main/java/client/gui/GuiMenu.java index cea6cff..0e68bf1 100644 --- a/client/src/main/java/client/gui/GuiMenu.java +++ b/client/src/main/java/client/gui/GuiMenu.java @@ -9,6 +9,7 @@ import client.gui.element.Label; import client.gui.element.NavButton; import client.gui.element.PressType; import client.gui.options.GuiOptions; +import client.network.DummyPlayer; import client.renderer.Drawing; import client.window.Keysym; import common.color.TextColor; @@ -53,6 +54,10 @@ public class GuiMenu extends Gui { this.resetAnimation(); this.add(new ActButton(0, -28, 400, 24, new ButtonCallback() { public void use(ActButton elem, PressType action) { + if(action == PressType.SECONDARY) { + new DummyPlayer(GuiMenu.this.gm).join(); + return; + } if(GuiMenu.this.hacked == 9) { GuiMenu.this.hacked++; GuiMenu.this.splashLabel.setText(TextColor.VIOLET + "Hax!"); diff --git a/client/src/main/java/client/gui/character/GuiCharacters.java b/client/src/main/java/client/gui/character/GuiCharacters.java index 99f7d96..660dc0d 100644 --- a/client/src/main/java/client/gui/character/GuiCharacters.java +++ b/client/src/main/java/client/gui/character/GuiCharacters.java @@ -13,6 +13,7 @@ import client.renderer.Drawing; import common.color.TextColor; import common.entity.npc.PlayerCharacter; import common.packet.CPacketAction; +import common.util.ExtMath; public class GuiCharacters extends GuiList implements ButtonCallback { @@ -71,14 +72,12 @@ public class GuiCharacters extends GuiList impleme super.init(width, height); this.setDimensions(600, height, 32, height - 32); this.elements.clear(); - if(this.gm.getNetHandler() != null) { - int initialSelection = this.gm.getNetHandler().getSelectedCharacter(); - for(PlayerCharacter character : this.gm.getNetHandler().getCharacterList()) { - this.elements.add(new CharacterEntry(initialSelection == this.elements.size() ? new PlayerCharacter(character.name(), character.info(), character.align(), this.gm.player.worldObj.dimension.getFormattedName(false), this.gm.player.getPosition(), character.type(), this.gm.player.experienceLevel) : character, initialSelection == this.elements.size())); - } - this.elements.add(new CharacterEntry(null, false)); - this.setSelected(initialSelection); - } + int selected = this.gm.selectedCharacter; + for(PlayerCharacter character : this.gm.characterList) { + this.elements.add(new CharacterEntry(selected == this.elements.size() ? new PlayerCharacter(character.name(), character.info(), character.align(), this.gm.player.worldObj.dimension.getFormattedName(false), this.gm.player.getPosition(), character.type(), this.gm.player.experienceLevel) : character, selected == this.elements.size())); + } + this.elements.add(new CharacterEntry(null, false)); + this.setSelected(ExtMath.clampi(selected, -1, this.elements.size() - 1)); this.descField = this.add(new TransparentArea(width - 390, 62, 380, height - 124, "", false)); this.deleteButtom = this.add(new ActButton(width / 2 - 304, height - 28, 200, 24, this, "Charakter löschen")); this.actionButtom = this.add(new ActButton(width / 2 - 100, height - 28, 200, 24, this, "")); diff --git a/client/src/main/java/client/network/ClientLoginHandler.java b/client/src/main/java/client/network/ClientLoginHandler.java index ab32ec8..5dced68 100755 --- a/client/src/main/java/client/network/ClientLoginHandler.java +++ b/client/src/main/java/client/network/ClientLoginHandler.java @@ -198,7 +198,6 @@ public class ClientLoginHandler implements IClientLoginHandler { return; } this.state = LoginState.DONE; - this.gm.debugWorld = packet.isDebug(); this.connection.setConnectionState(PacketRegistry.PLAY); this.connection.setNetHandler(new ClientPlayer(this.gm, this.connection)); } diff --git a/client/src/main/java/client/network/ClientPlayer.java b/client/src/main/java/client/network/ClientPlayer.java index 0a061ba..b07ef0d 100755 --- a/client/src/main/java/client/network/ClientPlayer.java +++ b/client/src/main/java/client/network/ClientPlayer.java @@ -1,11 +1,7 @@ package client.network; -import java.util.Collection; import java.util.List; -import java.util.Map; import java.util.Map.Entry; -import java.util.Set; - import client.Client; import client.gui.Gui; import client.gui.GuiConsole; @@ -36,8 +32,6 @@ import common.attributes.AttributeMap; import common.attributes.AttributeModifier; import common.block.Block; import common.block.tech.BlockWorkbench; -import common.collect.Lists; -import common.collect.Maps; import common.dimension.Dimension; import common.entity.DataWatcher; import common.entity.Entity; @@ -146,97 +140,88 @@ import common.world.World; public class ClientPlayer implements IClientPlayer { - /** - * The NetworkManager instance used to communicate with the server (used only by handlePlayerPosLook to update - * positioning and handleJoinGame to inform the server of the client distribution/mods) - */ - private final NetConnection netManager; + protected final Client gm; + private final NetConnection connection; + private WorldClient world; + private boolean loaded; + private final Random rand = new Random(); - /** - * Reference to the Game instance, which many handler methods operate on - */ - private Client gameController; - - /** - * Reference to the current ClientWorld instance, which many handler methods operate on - */ - private WorldClient clientWorldController; - - /** - * True if the client has finished downloading terrain and may spawn. Set upon receipt of S08PacketPlayerPosLook, - * reset upon respawning - */ - private boolean doneLoadingTerrain; -// private boolean travelSound; - private final Map playerList = Maps.newTreeMap(); - private final List characterList = Lists.newArrayList(); -// private final List> players = Lists.newArrayList(); - private int selectedCharacter = -1; - - /** - * Just an ordinary random number generator, used to randomize audio pitch of item/orb pickup and randomize both - * particlespawn offset and velocity - */ - private final Random avRandomizer = new Random(); - - public ClientPlayer(Client gmIn, NetConnection p_i46300_3_) + public ClientPlayer(Client gm, NetConnection connection) { - this.gameController = gmIn; - this.netManager = p_i46300_3_; + this.gm = gm; + this.connection = connection; + } + + + public final boolean isJumping() { + return this.gm.jump; + } + + public final boolean isSprinting() { + return this.gm.sprint; + } + + public final boolean isSneaking() { + return this.gm.sneak; + } + + public final float getMoveForward() { + return this.gm.moveForward; + } + + public final float getMoveStrafe() { + return this.gm.moveStrafe; + } + + public final void setMoveForward(float value) { + this.gm.moveForward = value; + } + + public final void setMoveStrafe(float value) { + this.gm.moveStrafe = value; + } + + public final boolean isRenderViewEntity(Entity entity) { + return this.gm.getRenderViewEntity() == entity; + } + + public final void updatePlayerMoveState() { + this.gm.updatePlayerMoveState(); + } + + public final void closeGui() { + this.gm.displayGuiScreen(null); + } + + public final NetConnection getConnection() { + return this.connection; } public void playSound(Sound sound) { - this.gameController.getSoundManager().playSound(sound); + this.gm.getSoundManager().playSound(sound); } public void emitParticleAtEntity(Entity entityIn, ParticleType particleTypes) { - this.gameController.effectRenderer.emitParticleAtEntity(entityIn, particleTypes); + this.gm.effectRenderer.emitParticleAtEntity(entityIn, particleTypes); } - - public boolean isJumping() { - return this.gameController.jump; - } - - public boolean isSprinting() { - return this.gameController.sprint; - } - - public boolean isSneaking() { - return this.gameController.sneak; - } - - public float getMoveForward() { - return this.gameController.moveForward; - } - - public float getMoveStrafe() { - return this.gameController.moveStrafe; - } - - public void setMoveForward(float value) { - this.gameController.moveForward = value; - } - - public void setMoveStrafe(float value) { - this.gameController.moveStrafe = value; - } - - public boolean isRenderViewEntity(Entity entity) { - return this.gameController.getRenderViewEntity() == entity; - } - public void updatePlayerMoveState() { - this.gameController.updatePlayerMoveState(); + public void onDisconnect(String reason) + { + this.gm.disconnected(reason); + } + + public void addToSendQueue(Packet p_147297_1_) + { + this.connection.sendPacket(p_147297_1_); } - /** * Clears the WorldClient instance associated with this NetHandlerPlayClient */ public void cleanup() { - this.clientWorldController = null; + this.world = null; // for(String user : this.playerInfoMap.keySet()) { // DefaultPlayerSkin.setTexture(user, null); // } @@ -246,15 +231,15 @@ public class ClientPlayer implements IClientPlayer public void handleJoinGame(SPacketJoinGame packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController); - this.gameController.charEditor = packetIn.isInEditor(); - this.gameController.controller = new PlayerController(this.gameController, this); - this.clientWorldController = new WorldClient(this.gameController, this.gameController.debugWorld, packetIn.getDimension()); + NetHandler.checkThread(packetIn, this, this.gm); + this.gm.charEditor = packetIn.isInEditor(); + this.gm.controller = new PlayerController(this.gm, this); + this.world = new WorldClient(this.gm, false, packetIn.getDimension()); // this.gameController.gameSettings.difficulty = packetIn.getDifficulty(); - this.gameController.loadWorld(this.clientWorldController, packetIn.getEntityType()); + this.gm.loadWorld(this.world, packetIn.getEntityType()); // this.gameController.thePlayer.dimension = this.clientWorldController.dimension.getDimensionId(); - this.gameController.player.setId(packetIn.getEntityId()); - this.gameController.displayGuiScreen(this.gameController.charEditor ? GuiChar.INSTANCE : null); + this.gm.player.setId(packetIn.getEntityId()); + this.gm.displayGuiScreen(this.gm.charEditor ? GuiChar.INSTANCE : null); // this.currentServerMaxPlayers = packetIn.getMaxPlayers(); // this.gameController.controller.setCheat(packetIn.getCheat()); // this.gameController.updateViewDistance(); @@ -272,7 +257,7 @@ public class ClientPlayer implements IClientPlayer */ public void handleSpawnObject(SPacketSpawnObject packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); + NetHandler.checkThread(packetIn, this, this.gm, this.world); double d0 = (double)packetIn.getX() / 32.0D; double d1 = (double)packetIn.getY() / 32.0D; double d2 = (double)packetIn.getZ() / 32.0D; @@ -295,7 +280,7 @@ public class ClientPlayer implements IClientPlayer // packetIn.setData(0); // } // else { - entity = EntityRegistry.createEntityByID(packetIn.getType(), this.clientWorldController, d0, d1, d2, packetIn.getData()); + entity = EntityRegistry.createEntityByID(packetIn.getType(), this.world, d0, d1, d2, packetIn.getData()); // } if(entity != null && entity.dead) { entity = null; @@ -413,7 +398,7 @@ public class ClientPlayer implements IClientPlayer } entity.setId(packetIn.getEntityID()); - this.clientWorldController.addEntityToWorld(packetIn.getEntityID(), entity); + this.world.addEntityToWorld(packetIn.getEntityID(), entity); if(entity instanceof EntityProjectile) { ((EntityProjectile)entity).setAcceleration((double)packetIn.getSpeedX() / 8000.0D, (double)packetIn.getSpeedY() / 8000.0D, (double)packetIn.getSpeedZ() / 8000.0D); @@ -456,7 +441,7 @@ public class ClientPlayer implements IClientPlayer */ public void handleSpawnGlobalEntity(SPacketSpawnGlobalEntity packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); + NetHandler.checkThread(packetIn, this, this.gm, this.world); double d0 = (double)packetIn.getEncodedX() / 32.0D; double d1 = (double)packetIn.getEncodedY() / 32.0D; double d2 = (double)packetIn.getEncodedZ() / 32.0D; @@ -464,7 +449,7 @@ public class ClientPlayer implements IClientPlayer if (packetIn.getType() == 1) { - entity = new EntityLightning(this.clientWorldController, d0, d1, d2, packetIn.getData(), 0, false, null); + entity = new EntityLightning(this.world, d0, d1, d2, packetIn.getData(), 0, false, null); } if (entity != null) @@ -475,7 +460,7 @@ public class ClientPlayer implements IClientPlayer entity.rotYaw = 0.0F; entity.rotPitch = 0.0F; entity.setId(packetIn.getEntityId()); - this.clientWorldController.effects.add(entity); + this.world.effects.add(entity); } } @@ -494,8 +479,8 @@ public class ClientPlayer implements IClientPlayer */ public void handleEntityVelocity(SPacketEntityVelocity packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); - Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityID()); + NetHandler.checkThread(packetIn, this, this.gm, this.world); + Entity entity = this.world.getEntityByID(packetIn.getEntityID()); if (entity != null) { @@ -509,15 +494,15 @@ public class ClientPlayer implements IClientPlayer */ public void handleEntityMetadata(SPacketEntityMetadata packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); - Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId()); + NetHandler.checkThread(packetIn, this, this.gm, this.world); + Entity entity = this.world.getEntityByID(packetIn.getEntityId()); if (entity != null && packetIn.func_149376_c() != null) { entity.getDataWatcher().updateWatchedObjectsFromList(packetIn.func_149376_c()); - if(entity == this.gameController.player && this.gameController.open instanceof GuiChar) - ((GuiChar)this.gameController.open).checkReopen(); + if(entity == this.gm.player && this.gm.open instanceof GuiChar) + ((GuiChar)this.gm.open).checkReopen(); } } @@ -526,13 +511,13 @@ public class ClientPlayer implements IClientPlayer */ public void handleSpawnPlayer(SPacketSpawnPlayer packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); + NetHandler.checkThread(packetIn, this, this.gm, this.world); double x = (double)packetIn.getX() / 32.0D; double y = (double)packetIn.getY() / 32.0D; double z = (double)packetIn.getZ() / 32.0D; float yaw = packetIn.getYaw(); float pitch = packetIn.getPitch(); - EntityNPC player = (EntityNPC)EntityRegistry.createEntityByID(packetIn.getEntityType(), this.gameController.world); // new EntityNPC(this.gameController.theWorld); // , /* this.getPlayerInfo( */ packetIn.getUser()); // ).getUser()); + EntityNPC player = (EntityNPC)EntityRegistry.createEntityByID(packetIn.getEntityType(), this.gm.world); // new EntityNPC(this.gameController.theWorld); // , /* this.getPlayerInfo( */ packetIn.getUser()); // ).getUser()); player.setOtherPlayer(); player.prevX = player.lastTickPosX = (double)(player.serverPosX = packetIn.getX()); player.prevY = player.lastTickPosY = (double)(player.serverPosY = packetIn.getY()); @@ -550,7 +535,7 @@ public class ClientPlayer implements IClientPlayer } player.setPositionAndRotation(x, y, z, yaw, pitch); - this.clientWorldController.addEntityToWorld(packetIn.getEntityID(), player); + this.world.addEntityToWorld(packetIn.getEntityID(), player); List list = packetIn.getData(); if (list != null) @@ -566,8 +551,8 @@ public class ClientPlayer implements IClientPlayer */ public void handleEntityTeleport(SPacketEntityTeleport packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); - Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId()); + NetHandler.checkThread(packetIn, this, this.gm, this.world); + Entity entity = this.world.getEntityByID(packetIn.getEntityId()); if (entity != null) { @@ -598,11 +583,11 @@ public class ClientPlayer implements IClientPlayer */ public void handleHeldItemChange(SPacketHeldItemChange packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); + NetHandler.checkThread(packetIn, this, this.gm, this.world); if (packetIn.getHeldItemHotbarIndex() >= 0 && packetIn.getHeldItemHotbarIndex() < InventoryPlayer.getHotbarSize()) { - this.gameController.player.inventory.currentItem = packetIn.getHeldItemHotbarIndex(); + this.gm.player.inventory.currentItem = packetIn.getHeldItemHotbarIndex(); } } @@ -613,8 +598,8 @@ public class ClientPlayer implements IClientPlayer */ public void handleEntityMovement(SPacketEntity packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); - Entity entity = packetIn.getEntity(this.clientWorldController); + NetHandler.checkThread(packetIn, this, this.gm, this.world); + Entity entity = packetIn.getEntity(this.world); if (entity != null) { @@ -637,8 +622,8 @@ public class ClientPlayer implements IClientPlayer */ public void handleEntityHeadLook(SPacketEntityHeadLook packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); - Entity entity = packetIn.getEntity(this.clientWorldController); + NetHandler.checkThread(packetIn, this, this.gm, this.world); + Entity entity = packetIn.getEntity(this.world); if (entity != null) { @@ -654,11 +639,11 @@ public class ClientPlayer implements IClientPlayer */ public void handleDestroyEntities(SPacketDestroyEntities packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); + NetHandler.checkThread(packetIn, this, this.gm, this.world); for (int i = 0; i < packetIn.getEntityIDs().length; ++i) { - this.clientWorldController.removeEntityFromWorld(packetIn.getEntityIDs()[i]); + this.world.removeEntityFromWorld(packetIn.getEntityIDs()[i]); EntityTexManager.setTexture(packetIn.getEntityIDs()[i], null, null); } } @@ -670,8 +655,8 @@ public class ClientPlayer implements IClientPlayer */ public void handlePlayerPosLook(SPacketPlayerPosLook packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); - EntityNPC entityplayer = this.gameController.player; + NetHandler.checkThread(packetIn, this, this.gm, this.world); + EntityNPC entityplayer = this.gm.player; double d0 = packetIn.getX(); double d1 = packetIn.getY(); double d2 = packetIn.getZ(); @@ -716,15 +701,15 @@ public class ClientPlayer implements IClientPlayer } entityplayer.setPositionAndRotation(d0, d1, d2, f, f1); - this.netManager.sendPacket(new CPacketPlayerPosLook(entityplayer.posX, entityplayer.getEntityBoundingBox().minY, entityplayer.posZ, entityplayer.rotYaw, entityplayer.rotPitch, false)); + this.connection.sendPacket(new CPacketPlayerPosLook(entityplayer.posX, entityplayer.getEntityBoundingBox().minY, entityplayer.posZ, entityplayer.rotYaw, entityplayer.rotPitch, false)); - if (!this.doneLoadingTerrain) + if (!this.loaded) { - this.gameController.player.prevX = this.gameController.player.posX; - this.gameController.player.prevY = this.gameController.player.posY; - this.gameController.player.prevZ = this.gameController.player.posZ; - this.doneLoadingTerrain = true; - this.clientWorldController.markReload(); + this.gm.player.prevX = this.gm.player.posX; + this.gm.player.prevY = this.gm.player.posY; + this.gm.player.prevZ = this.gm.player.posZ; + this.loaded = true; + this.world.markReload(); // this.gameController.displayGuiScreen(null); // if(this.travelSound) { // this.gameController.getSoundManager().playSound(new PositionedSound(SoundEvent.TELEPORT)); @@ -741,11 +726,11 @@ public class ClientPlayer implements IClientPlayer */ public void handleMultiBlockChange(SPacketMultiBlockChange packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); + NetHandler.checkThread(packetIn, this, this.gm, this.world); for (SPacketMultiBlockChange.BlockUpdateData update : packetIn.getChangedBlocks()) { - this.clientWorldController.invalidateRegionAndSetBlock(SPacketMultiBlockChange.getPos(packetIn.getChunkPos(), update.getRawPos()), update.getBlockState()); + this.world.invalidateRegionAndSetBlock(SPacketMultiBlockChange.getPos(packetIn.getChunkPos(), update.getRawPos()), update.getBlockState()); } } @@ -754,25 +739,25 @@ public class ClientPlayer implements IClientPlayer */ public void handleChunkData(SPacketChunkData packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); + NetHandler.checkThread(packetIn, this, this.gm, this.world); if (packetIn.hasBiomes()) { if (packetIn.getExtractedExtend().length == 0) { - this.clientWorldController.doPreChunk(packetIn.getChunkX(), packetIn.getChunkZ(), false); + this.world.doPreChunk(packetIn.getChunkX(), packetIn.getChunkZ(), false); return; } - this.clientWorldController.doPreChunk(packetIn.getChunkX(), packetIn.getChunkZ(), true); + this.world.doPreChunk(packetIn.getChunkX(), packetIn.getChunkZ(), true); } // this.clientWorldController.invalidateBlockReceiveRegion(packetIn.getChunkX() << 4, 0, packetIn.getChunkZ() << 4, (packetIn.getChunkX() << 4) + 15, 512, (packetIn.getChunkZ() << 4) + 15); - ChunkClient chunk = this.clientWorldController.getChunk(packetIn.getChunkX(), packetIn.getChunkZ()); + ChunkClient chunk = this.world.getChunk(packetIn.getChunkX(), packetIn.getChunkZ()); chunk.setData(packetIn.getExtractedDataBytes(), packetIn.getExtractedExtend(), packetIn.hasBiomes()); - this.clientWorldController.markBlockRangeForRenderUpdate(packetIn.getChunkX() << 4, -World.MAX_SIZE_Y, packetIn.getChunkZ() << 4, (packetIn.getChunkX() << 4) + 15, World.MAX_SIZE_Y, (packetIn.getChunkZ() << 4) + 15); + this.world.markBlockRangeForRenderUpdate(packetIn.getChunkX() << 4, -World.MAX_SIZE_Y, packetIn.getChunkZ() << 4, (packetIn.getChunkX() << 4) + 15, World.MAX_SIZE_Y, (packetIn.getChunkZ() << 4) + 15); - if (!packetIn.hasBiomes() || this.clientWorldController.dimension.hasNoLight()) // TODO: check + if (!packetIn.hasBiomes() || this.world.dimension.hasNoLight()) // TODO: check { chunk.resetRelight(); } @@ -780,10 +765,10 @@ public class ClientPlayer implements IClientPlayer public void handleBiomes(SPacketBiome packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); - ChunkClient chunk = this.clientWorldController.getChunk(packetIn.getChunkX(), packetIn.getChunkZ()); + NetHandler.checkThread(packetIn, this, this.gm, this.world); + ChunkClient chunk = this.world.getChunk(packetIn.getChunkX(), packetIn.getChunkZ()); chunk.setBiome(packetIn.getPos(), packetIn.getBiome()); - this.clientWorldController.markBlockRangeForRenderUpdate(packetIn.getChunkX() << 4, -World.MAX_SIZE_Y, packetIn.getChunkZ() << 4, (packetIn.getChunkX() << 4) + 15, World.MAX_SIZE_Y, (packetIn.getChunkZ() << 4) + 15); + this.world.markBlockRangeForRenderUpdate(packetIn.getChunkX() << 4, -World.MAX_SIZE_Y, packetIn.getChunkZ() << 4, (packetIn.getChunkX() << 4) + 15, World.MAX_SIZE_Y, (packetIn.getChunkZ() << 4) + 15); } /** @@ -791,8 +776,8 @@ public class ClientPlayer implements IClientPlayer */ public void handleBlockChange(SPacketBlockChange packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); - this.clientWorldController.invalidateRegionAndSetBlock(packetIn.getBlockPosition(), packetIn.getBlockState()); + NetHandler.checkThread(packetIn, this, this.gm, this.world); + this.world.invalidateRegionAndSetBlock(packetIn.getBlockPosition(), packetIn.getBlockState()); } /** @@ -800,43 +785,33 @@ public class ClientPlayer implements IClientPlayer */ public void handleDisconnect(SPacketDisconnect packetIn) { - this.netManager.closeChannel(packetIn.getMessage()); - } - - public void onDisconnect(String reason) - { - this.gameController.disconnected(reason); - } - - public void addToSendQueue(Packet p_147297_1_) - { - this.netManager.sendPacket(p_147297_1_); + this.connection.closeChannel(packetIn.getMessage()); } public void handleCollectItem(SPacketCollectItem packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); - Entity entity = this.clientWorldController.getEntityByID(packetIn.getCollectedItemEntityID()); - EntityLiving entitylivingbase = (EntityLiving)this.clientWorldController.getEntityByID(packetIn.getEntityID()); + NetHandler.checkThread(packetIn, this, this.gm, this.world); + Entity entity = this.world.getEntityByID(packetIn.getCollectedItemEntityID()); + EntityLiving entitylivingbase = (EntityLiving)this.world.getEntityByID(packetIn.getEntityID()); if (entitylivingbase == null) { - entitylivingbase = this.gameController.player; + entitylivingbase = this.gm.player; } if (entity != null) { if (entity instanceof EntityXp) { - this.clientWorldController.playSoundAtEntity(entity, SoundEvent.ORB, 0.2F); + this.world.playSoundAtEntity(entity, SoundEvent.ORB, 0.2F); } else { - this.clientWorldController.playSoundAtEntity(entity, SoundEvent.POP, 0.2F); + this.world.playSoundAtEntity(entity, SoundEvent.POP, 0.2F); } - this.gameController.effectRenderer.addEffect(new EntityPickupFX(this.clientWorldController, entity, entitylivingbase, 0.5F)); - this.clientWorldController.removeEntityFromWorld(packetIn.getCollectedItemEntityID()); + this.gm.effectRenderer.addEffect(new EntityPickupFX(this.world, entity, entitylivingbase, 0.5F)); + this.world.removeEntityFromWorld(packetIn.getCollectedItemEntityID()); } } @@ -845,44 +820,44 @@ public class ClientPlayer implements IClientPlayer */ public void handleMessage(SPacketMessage packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController); + NetHandler.checkThread(packetIn, this, this.gm); // if(this.gameController.chatVisibility == EnumChatVisibility.FULL || // (this.gameController.chatVisibility == EnumChatVisibility.SYSTEM && packetIn.isSystem())) // { switch(packetIn.getType()) { case CONSOLE: - this.gameController.logConsole(packetIn.getMessage()); + this.gm.logConsole(packetIn.getMessage()); break; case CHAT: - this.gameController.logChat(packetIn.getMessage()); + this.gm.logChat(packetIn.getMessage()); break; case FEED: - this.gameController.logFeed(packetIn.getMessage()); + this.gm.logFeed(packetIn.getMessage()); break; case HOTBAR: - this.gameController.logHotbar(packetIn.getMessage()); + this.gm.logHotbar(packetIn.getMessage()); break; } // } } public void handleLoading(SPacketLoading packet) { - NetHandler.checkThread(packet, this, this.gameController); + NetHandler.checkThread(packet, this, this.gm); if(packet.getMessage() == null) { if(packet.getTask() != null) - this.gameController.message = packet.getTask(); + this.gm.message = packet.getTask(); if(packet.getTotal() >= 0) - this.gameController.total = packet.getTotal(); + this.gm.total = packet.getTotal(); if(packet.getProgress() >= -1) - this.gameController.progress = packet.getProgress(); + this.gm.progress = packet.getProgress(); } else { - this.gameController.message = ""; - this.gameController.total = 0; - this.gameController.progress = -1; - this.gameController.displayGuiScreen(GuiLoading.makeServerTask(packet.getMessage())); + this.gm.message = ""; + this.gm.total = 0; + this.gm.progress = -1; + this.gm.displayGuiScreen(GuiLoading.makeServerTask(packet.getMessage())); } } @@ -907,8 +882,8 @@ public class ClientPlayer implements IClientPlayer */ public void handleAnimation(SPacketAnimation packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); - Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityID()); + NetHandler.checkThread(packetIn, this, this.gm, this.world); + Entity entity = this.world.getEntityByID(packetIn.getEntityID()); if (entity != null) { @@ -928,11 +903,11 @@ public class ClientPlayer implements IClientPlayer // } else if (packetIn.getAnimationType() == 4) { - this.gameController.effectRenderer.emitParticleAtEntity(entity, ParticleType.CRIT); + this.gm.effectRenderer.emitParticleAtEntity(entity, ParticleType.CRIT); } else if (packetIn.getAnimationType() == 5) { - this.gameController.effectRenderer.emitParticleAtEntity(entity, ParticleType.CRIT_MAGIC); + this.gm.effectRenderer.emitParticleAtEntity(entity, ParticleType.CRIT_MAGIC); } } } @@ -953,13 +928,13 @@ public class ClientPlayer implements IClientPlayer */ public void handleSpawnMob(SPacketSpawnMob packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); + NetHandler.checkThread(packetIn, this, this.gm, this.world); double d0 = (double)packetIn.getX() / 32.0D; double d1 = (double)packetIn.getY() / 32.0D; double d2 = (double)packetIn.getZ() / 32.0D; float f = (float)(packetIn.getYaw() * 360) / 256.0F; float f1 = (float)(packetIn.getPitch() * 360) / 256.0F; - EntityLiving entitylivingbase = (EntityLiving)EntityRegistry.createEntityByID(packetIn.getEntityType(), this.gameController.world); + EntityLiving entitylivingbase = (EntityLiving)EntityRegistry.createEntityByID(packetIn.getEntityType(), this.gm.world); entitylivingbase.serverPosX = packetIn.getX(); entitylivingbase.serverPosY = packetIn.getY(); entitylivingbase.serverPosZ = packetIn.getZ(); @@ -981,7 +956,7 @@ public class ClientPlayer implements IClientPlayer entitylivingbase.motionX = (double)((float)packetIn.getVelocityX() / 8000.0F); entitylivingbase.motionY = (double)((float)packetIn.getVelocityY() / 8000.0F); entitylivingbase.motionZ = (double)((float)packetIn.getVelocityZ() / 8000.0F); - this.clientWorldController.addEntityToWorld(packetIn.getEntityID(), entitylivingbase); + this.world.addEntityToWorld(packetIn.getEntityID(), entitylivingbase); List list = packetIn.getMetadata(); if (list != null) @@ -992,16 +967,16 @@ public class ClientPlayer implements IClientPlayer public void handleTimeUpdate(SPacketTimeUpdate packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); + NetHandler.checkThread(packetIn, this, this.gm, this.world); // this.gameController.theWorld.getWorldInfo().setTime(packetIn.getTotalWorldTime()); - this.gameController.world.setDayTime(packetIn.getWorldTime()); - this.gameController.setTicked(packetIn.getServerinfo()); + this.gm.world.setDayTime(packetIn.getWorldTime()); + this.gm.setTicked(packetIn.getServerinfo()); } public void handleServerTick(SPacketServerTick packet) { - NetHandler.checkThread(packet, this, this.gameController); - this.gameController.setLastTick(packet.getTime()); + NetHandler.checkThread(packet, this, this.gm); + this.gm.setLastTick(packet.getTime()); } // public void handleCompass(SPacketCompass packetIn) @@ -1012,17 +987,17 @@ public class ClientPlayer implements IClientPlayer public void handleEntityAttach(SPacketEntityAttach packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); - Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId()); - Entity entity1 = this.clientWorldController.getEntityByID(packetIn.getVehicleEntityId()); + NetHandler.checkThread(packetIn, this, this.gm, this.world); + Entity entity = this.world.getEntityByID(packetIn.getEntityId()); + Entity entity1 = this.world.getEntityByID(packetIn.getVehicleEntityId()); if (packetIn.getLeash() == 0) { // boolean flag = false; - if (packetIn.getEntityId() == this.gameController.player.getId()) + if (packetIn.getEntityId() == this.gm.player.getId()) { - entity = this.gameController.player; + entity = this.gm.player; if (entity1 instanceof EntityBoat) { @@ -1069,8 +1044,8 @@ public class ClientPlayer implements IClientPlayer */ public void handleEntityStatus(SPacketEntityStatus packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); - Entity entity = packetIn.getEntity(this.clientWorldController); + NetHandler.checkThread(packetIn, this, this.gm, this.world); + Entity entity = packetIn.getEntity(this.world); if (entity != null) { @@ -1087,42 +1062,42 @@ public class ClientPlayer implements IClientPlayer public void handleUpdateHealth(SPacketUpdateHealth packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); - this.gameController.player.setPlayerSPHealth(packetIn.getHealth()); + NetHandler.checkThread(packetIn, this, this.gm, this.world); + this.gm.player.setPlayerSPHealth(packetIn.getHealth()); // this.gameController.thePlayer.getFoodStats().setFoodLevel(packetIn.getFoodLevel()); // this.gameController.thePlayer.getFoodStats().setFoodSaturationLevel(packetIn.getSaturationLevel()); } public void handleSetExperience(SPacketSetExperience packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); - this.gameController.player.setXPStats(packetIn.getProgress(), packetIn.getTotalExperience(), packetIn.getLevel()); + NetHandler.checkThread(packetIn, this, this.gm, this.world); + this.gm.player.setXPStats(packetIn.getProgress(), packetIn.getTotalExperience(), packetIn.getLevel()); } public void handleRespawn(SPacketRespawn packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); - this.gameController.charEditor = packetIn.isInEditor(); + NetHandler.checkThread(packetIn, this, this.gm, this.world); + this.gm.charEditor = packetIn.isInEditor(); Dimension dim = packetIn.getDimension(); - if (dim.getDimensionId() != this.clientWorldController.dimension.getDimensionId()) // this.gameController.thePlayer.dimension) + if (dim.getDimensionId() != this.world.dimension.getDimensionId()) // this.gameController.thePlayer.dimension) { - this.doneLoadingTerrain = false; + this.loaded = false; // if(dim.getDimensionId() < 0 && this.gameController.thePlayer.dimension >= 0) { // this.travelSound = "portal.travel"; // } // Scoreboard scoreboard = this.clientWorldController.getScoreboard(); - this.clientWorldController = new WorldClient(this.gameController, this.gameController.debugWorld, dim); + this.world = new WorldClient(this.gm, false, dim); // this.clientWorldController.setWorldScoreboard(scoreboard); - this.gameController.loadWorld(this.clientWorldController, packetIn.getEntityType()); + this.gm.loadWorld(this.world, packetIn.getEntityType()); // this.gameController.thePlayer.dimension = dim.getDimensionId(); } // else if(this.gameController.charEditor) { // this.gameController.displayGuiScreen(GuiSkin.INSTANCE); // } - this.gameController.setDimensionAndSpawnPlayer(dim.getDimensionId(), packetIn.getEntityType()); - this.gameController.displayGuiScreen(this.gameController.charEditor ? GuiChar.INSTANCE : null); + this.gm.setDimensionAndSpawnPlayer(dim.getDimensionId(), packetIn.getEntityType()); + this.gm.displayGuiScreen(this.gm.charEditor ? GuiChar.INSTANCE : null); // this.gameController.controller.setCheat(packetIn.getCheat()); } @@ -1131,12 +1106,12 @@ public class ClientPlayer implements IClientPlayer */ public void handleExplosion(SPacketExplosion packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); - Explosion explosion = new Explosion(this.gameController.world, (Entity)null, packetIn.getX(), packetIn.getY(), packetIn.getZ(), packetIn.getStrength(), packetIn.getAffectedBlockPositions()); + NetHandler.checkThread(packetIn, this, this.gm, this.world); + Explosion explosion = new Explosion(this.gm.world, (Entity)null, packetIn.getX(), packetIn.getY(), packetIn.getZ(), packetIn.getStrength(), packetIn.getAffectedBlockPositions()); explosion.doExplosionB(true, packetIn.hasAltSound()); - this.gameController.player.motionX += (double)packetIn.func_149149_c(); - this.gameController.player.motionY += (double)packetIn.func_149144_d(); - this.gameController.player.motionZ += (double)packetIn.func_149147_e(); + this.gm.player.motionX += (double)packetIn.func_149149_c(); + this.gm.player.motionY += (double)packetIn.func_149144_d(); + this.gm.player.motionZ += (double)packetIn.func_149147_e(); } /** @@ -1145,8 +1120,8 @@ public class ClientPlayer implements IClientPlayer */ public void handleOpenWindow(SPacketOpenWindow packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); - EntityNPC entityplayersp = this.gameController.player; + NetHandler.checkThread(packetIn, this, this.gm, this.world); + EntityNPC entityplayersp = this.gm.player; if ("container".equals(packetIn.getGuiId())) { @@ -1160,7 +1135,7 @@ public class ClientPlayer implements IClientPlayer } else if ("EntityHorse".equals(packetIn.getGuiId())) { - Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId()); + Entity entity = this.world.getEntityByID(packetIn.getEntityId()); if (entity instanceof EntityHorse) { @@ -1178,9 +1153,9 @@ public class ClientPlayer implements IClientPlayer ContainerLocalMenu containerlocalmenu = new ContainerLocalMenu(packetIn.getGuiId(), packetIn.getWindowTitle(), packetIn.getSlotCount()); if (packetIn.getGuiId().startsWith("machine_")) { - TileEntity machine = this.clientWorldController.getTileEntity(packetIn.getTilePos()); + TileEntity machine = this.world.getTileEntity(packetIn.getTilePos()); if(machine instanceof TileEntityMachine) - this.gameController.displayGuiScreen(new GuiMachine(this.gameController.player.inventory, containerlocalmenu, (TileEntityMachine)machine)); + this.gm.displayGuiScreen(new GuiMachine(this.gm.player.inventory, containerlocalmenu, (TileEntityMachine)machine)); } else { entityplayersp.displayGUIChest(containerlocalmenu); @@ -1194,8 +1169,8 @@ public class ClientPlayer implements IClientPlayer */ public void handleSetSlot(SPacketSetSlot packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); - EntityNPC entityplayer = this.gameController.player; + NetHandler.checkThread(packetIn, this, this.gm, this.world); + EntityNPC entityplayer = this.gm.player; if (packetIn.getWindowId() == -1) { @@ -1235,9 +1210,9 @@ public class ClientPlayer implements IClientPlayer */ public void handleConfirmTransaction(SPacketConfirmTransaction packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); + NetHandler.checkThread(packetIn, this, this.gm, this.world); Container container = null; - EntityNPC entityplayer = this.gameController.player; + EntityNPC entityplayer = this.gm.player; if (packetIn.getWindowId() == 0) { @@ -1259,8 +1234,8 @@ public class ClientPlayer implements IClientPlayer */ public void handleWindowItems(SPacketWindowItems packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); - EntityNPC entityplayer = this.gameController.player; + NetHandler.checkThread(packetIn, this, this.gm, this.world); + EntityNPC entityplayer = this.gm.player; if (packetIn.func_148911_c() == 0) { @@ -1277,22 +1252,22 @@ public class ClientPlayer implements IClientPlayer */ public void handleSignEditorOpen(SPacketSignEditorOpen packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); - TileEntity tileentity = this.clientWorldController.getTileEntity(packetIn.getSignPosition()); + NetHandler.checkThread(packetIn, this, this.gm, this.world); + TileEntity tileentity = this.world.getTileEntity(packetIn.getSignPosition()); if (!(tileentity instanceof TileEntitySign)) { tileentity = new TileEntitySign(); - tileentity.setWorldObj(this.clientWorldController); + tileentity.setWorldObj(this.world); tileentity.setPos(packetIn.getSignPosition()); } - this.gameController.player.openEditSign((TileEntitySign)tileentity); + this.gm.player.openEditSign((TileEntitySign)tileentity); } public void handleForm(SPacketDisplayForm packet) { - NetHandler.checkThread(packet, this, this.gameController, this.clientWorldController); - this.gameController.displayGuiScreen(new GuiForm(packet.getId(), packet.getTitle(), packet.getData())); + NetHandler.checkThread(packet, this, this.gm, this.world); + this.gm.displayGuiScreen(new GuiForm(packet.getId(), packet.getTitle(), packet.getData())); } /** @@ -1300,12 +1275,12 @@ public class ClientPlayer implements IClientPlayer */ public void handleUpdateSign(SPacketUpdateSign packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); + NetHandler.checkThread(packetIn, this, this.gm, this.world); // boolean flag = false; - if (this.gameController.world.isBlockLoaded(packetIn.getPos())) + if (this.gm.world.isBlockLoaded(packetIn.getPos())) { - TileEntity tileentity = this.gameController.world.getTileEntity(packetIn.getPos()); + TileEntity tileentity = this.gm.world.getTileEntity(packetIn.getPos()); if (tileentity instanceof TileEntitySign) { @@ -1335,11 +1310,11 @@ public class ClientPlayer implements IClientPlayer */ public void handleUpdateTileEntity(SPacketUpdateTileEntity packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); + NetHandler.checkThread(packetIn, this, this.gm, this.world); - if (this.gameController.world.isBlockLoaded(packetIn.getPos())) + if (this.gm.world.isBlockLoaded(packetIn.getPos())) { - TileEntity tileentity = this.gameController.world.getTileEntity(packetIn.getPos()); + TileEntity tileentity = this.gm.world.getTileEntity(packetIn.getPos()); // int i = packetIn.getTileEntityType(); if (tileentity != null && packetIn.isTileEntityType(tileentity)) // i == 1 && tileentity instanceof TileEntityMobSpawner || /* i == 2 && tileentity instanceof TileEntityCommandBlock || */ i == 3 && tileentity instanceof TileEntityBeacon || i == 4 && tileentity instanceof TileEntitySkull || /* i == 5 && tileentity instanceof TileEntityFlowerPot || */ i == 6 && tileentity instanceof TileEntityBanner || i == 7 && tileentity instanceof TileEntityMachine) @@ -1354,8 +1329,8 @@ public class ClientPlayer implements IClientPlayer */ public void handleWindowProperty(SPacketWindowProperty packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); - EntityNPC entityplayer = this.gameController.player; + NetHandler.checkThread(packetIn, this, this.gm, this.world); + EntityNPC entityplayer = this.gm.player; if (entityplayer.openContainer != null && entityplayer.openContainer.windowId == packetIn.getWindowId()) { @@ -1365,8 +1340,8 @@ public class ClientPlayer implements IClientPlayer public void handleEntityEquipment(SPacketEntityEquipment packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); - Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityID()); + NetHandler.checkThread(packetIn, this, this.gm, this.world); + Entity entity = this.world.getEntityByID(packetIn.getEntityID()); if (entity != null) { @@ -1379,9 +1354,9 @@ public class ClientPlayer implements IClientPlayer */ public void handleCloseWindow(SPacketCloseWindow packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); + NetHandler.checkThread(packetIn, this, this.gm, this.world); // this.gameController.thePlayer.closeScreenAndDropStack(); - this.gameController.displayGuiScreen(null); + this.gm.displayGuiScreen(null); } /** @@ -1391,8 +1366,8 @@ public class ClientPlayer implements IClientPlayer */ public void handleBlockAction(SPacketBlockAction packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); - this.gameController.world.addBlockEvent(packetIn.getBlockPosition(), packetIn.getBlockType(), packetIn.getData1(), packetIn.getData2()); + NetHandler.checkThread(packetIn, this, this.gm, this.world); + this.gm.world.addBlockEvent(packetIn.getBlockPosition(), packetIn.getBlockType(), packetIn.getData1(), packetIn.getData2()); } /** @@ -1400,25 +1375,25 @@ public class ClientPlayer implements IClientPlayer */ public void handleBlockBreakAnim(SPacketBlockBreakAnim packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); - this.gameController.world.sendBlockBreakProgress(packetIn.getBreakerId(), packetIn.getPosition(), packetIn.getProgress()); + NetHandler.checkThread(packetIn, this, this.gm, this.world); + this.gm.world.sendBlockBreakProgress(packetIn.getBreakerId(), packetIn.getPosition(), packetIn.getProgress()); } public void handleMapChunkBulk(SPacketMapChunkBulk packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); + NetHandler.checkThread(packetIn, this, this.gm, this.world); for (int i = 0; i < packetIn.getChunkCount(); ++i) { int j = packetIn.getChunkX(i); int k = packetIn.getChunkZ(i); - this.clientWorldController.doPreChunk(j, k, true); + this.world.doPreChunk(j, k, true); // this.clientWorldController.invalidateBlockReceiveRegion(j << 4, 0, k << 4, (j << 4) + 15, 512, (k << 4) + 15); - ChunkClient chunk = this.clientWorldController.getChunk(j, k); + ChunkClient chunk = this.world.getChunk(j, k); chunk.setData(packetIn.getChunkBytes(i), packetIn.getChunkExtend(i), true); - this.clientWorldController.markBlockRangeForRenderUpdate(j << 4, -World.MAX_SIZE_Y, k << 4, (j << 4) + 15, World.MAX_SIZE_Y, (k << 4) + 15); + this.world.markBlockRangeForRenderUpdate(j << 4, -World.MAX_SIZE_Y, k << 4, (j << 4) + 15, World.MAX_SIZE_Y, (k << 4) + 15); - if (this.clientWorldController.dimension.hasNoLight()) // TODO: check + if (this.world.dimension.hasNoLight()) // TODO: check { chunk.resetRelight(); } @@ -1427,32 +1402,32 @@ public class ClientPlayer implements IClientPlayer public void handleChangeGameState(SPacketChangeGameState packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); + NetHandler.checkThread(packetIn, this, this.gm, this.world); switch(packetIn.getAction()) { // case SET_CHEAT: // this.gameController.controller.setCheat(packetIn.getInt() == 1); // break; case SET_WEATHER: - this.clientWorldController.setWeather(Weather.getByID(packetIn.getInt())); + this.world.setWeather(Weather.getByID(packetIn.getInt())); break; case RAIN_STRENGTH: - this.clientWorldController.setRainStrength(packetIn.getFloat(true)); + this.world.setRainStrength(packetIn.getFloat(true)); break; case DARKNESS: - this.clientWorldController.setDarkness(packetIn.getFloat(true)); + this.world.setDarkness(packetIn.getFloat(true)); break; case FOG_STRENGTH: - this.clientWorldController.setFogStrength(packetIn.getFloat(true)); + this.world.setFogStrength(packetIn.getFloat(true)); break; case TEMPERATURE: - this.clientWorldController.setTemperature(packetIn.getFloat(false)); + this.world.setTemperature(packetIn.getFloat(false)); break; } } public void handleEffect(SPacketEffect packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); + NetHandler.checkThread(packetIn, this, this.gm, this.world); // if (packetIn.isSoundServerwide()) // { @@ -1460,7 +1435,7 @@ public class ClientPlayer implements IClientPlayer // } // else // { - this.gameController.world.playAuxSFX(packetIn.getSoundType(), packetIn.getSoundPos(), packetIn.getSoundData()); + this.gm.world.playAuxSFX(packetIn.getSoundType(), packetIn.getSoundPos(), packetIn.getSoundData()); // } } @@ -1517,8 +1492,8 @@ public class ClientPlayer implements IClientPlayer public void handleEntityEffect(SPacketEntityEffect packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); - Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId()); + NetHandler.checkThread(packetIn, this, this.gm, this.world); + Entity entity = this.world.getEntityByID(packetIn.getEntityId()); if (entity instanceof EntityLiving) { @@ -1543,12 +1518,12 @@ public class ClientPlayer implements IClientPlayer public void handleCamera(SPacketCamera packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); - Entity entity = packetIn.getEntity(this.clientWorldController); + NetHandler.checkThread(packetIn, this, this.gm, this.world); + Entity entity = packetIn.getEntity(this.world); if (entity != null) { - this.gameController.setRenderViewEntity(entity); + this.gm.setRenderViewEntity(entity); } } @@ -1594,8 +1569,8 @@ public class ClientPlayer implements IClientPlayer public void handleRemoveEntityEffect(SPacketRemoveEntityEffect packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); - Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId()); + NetHandler.checkThread(packetIn, this, this.gm, this.world); + Entity entity = this.world.getEntityByID(packetIn.getEntityId()); if (entity instanceof EntityLiving) { @@ -1606,13 +1581,13 @@ public class ClientPlayer implements IClientPlayer public void handlePlayerListItem(SPacketPlayerListItem packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController); + NetHandler.checkThread(packetIn, this, this.gm); for(Entry data : packetIn.getEntries()) { if(data.getValue() < 0) - this.playerList.remove(data.getKey()); + this.gm.playerList.remove(data.getKey()); else - this.playerList.put(data.getKey(), data.getValue()); + this.gm.playerList.put(data.getKey(), data.getValue()); } // String[] list = new String[this.playerList.size()]; // int[] data = new int[this.playerList.size()]; @@ -1626,23 +1601,23 @@ public class ClientPlayer implements IClientPlayer public void handleCharacterList(SPacketCharacterList packet) { - NetHandler.checkThread(packet, this, this.gameController); + NetHandler.checkThread(packet, this, this.gm); for(Entry data : packet.getEntries()) { if(data.getValue() == null) - this.characterList.remove(data.getKey().intValue()); - else if(data.getKey() < this.characterList.size()) - this.characterList.set(data.getKey(), data.getValue()); + this.gm.characterList.remove(data.getKey().intValue()); + else if(data.getKey() < this.gm.characterList.size()) + this.gm.characterList.set(data.getKey(), data.getValue()); else - this.characterList.add(data.getKey(), data.getValue()); + this.gm.characterList.add(data.getKey(), data.getValue()); } - this.selectedCharacter = packet.getSelected(); - if(this.gameController.charEditor && this.selectedCharacter >= 0) { - this.gameController.charEditor = false; - this.gameController.displayGuiScreen(null); + this.gm.selectedCharacter = packet.getSelected(); + if(this.gm.charEditor && this.gm.selectedCharacter >= 0) { + this.gm.charEditor = false; + this.gm.displayGuiScreen(null); } - else if(this.gameController.open instanceof GuiCharacters) { - this.gameController.displayGuiScreen(this.gameController.open); + else if(this.gm.open instanceof GuiCharacters) { + this.gm.displayGuiScreen(this.gm.open); } } @@ -1653,8 +1628,8 @@ public class ClientPlayer implements IClientPlayer public void handlePlayerAbilities(SPacketPlayerAbilities packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); - EntityNPC entityplayer = this.gameController.player; + NetHandler.checkThread(packetIn, this, this.gm, this.world); + EntityNPC entityplayer = this.gm.player; entityplayer.flying = packetIn.isFlying(); entityplayer.noclip = packetIn.isNoclip(); // entityplayer.speed = packetIn.getSpeed(); @@ -1666,27 +1641,27 @@ public class ClientPlayer implements IClientPlayer */ public void handleTabComplete(SPacketTabComplete packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); + NetHandler.checkThread(packetIn, this, this.gm, this.world); String[] astring = packetIn.func_149630_c(); // this.gameController.complete(astring); - if (this.gameController.open instanceof GuiConsole) + if (this.gm.open instanceof GuiConsole) { - GuiConsole guichat = (GuiConsole)this.gameController.open; + GuiConsole guichat = (GuiConsole)this.gm.open; guichat.onAutocompleteResponse(astring); } } public void handleSoundEffect(SPacketSoundEffect packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); + NetHandler.checkThread(packetIn, this, this.gm, this.world); if(packetIn.getSound() == null) { - this.gameController.getSoundManager().stopSounds(); + this.gm.getSoundManager().stopSounds(); return; } // else if(packetIn.getSoundName().startsWith("music#")) { // return; // } - this.gameController.world.playSound(packetIn.getX(), packetIn.getY(), packetIn.getZ(), packetIn.getSound(), packetIn.getVolume()); + this.gm.world.playSound(packetIn.getX(), packetIn.getY(), packetIn.getZ(), packetIn.getSound(), packetIn.getVolume()); } // public void handleDisplay(S48PacketDisplay packetIn) @@ -1715,8 +1690,8 @@ public class ClientPlayer implements IClientPlayer public void handleEntityTags(SPacketUpdateEntityTags packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); - Entity entity = packetIn.getEntity(this.clientWorldController); + NetHandler.checkThread(packetIn, this, this.gm, this.world); + Entity entity = packetIn.getEntity(this.world); if (entity != null) { @@ -1839,7 +1814,7 @@ public class ClientPlayer implements IClientPlayer */ public void handleParticles(SPacketParticles packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); + NetHandler.checkThread(packetIn, this, this.gm, this.world); if (packetIn.getParticleCount() == 0) { @@ -1850,7 +1825,7 @@ public class ClientPlayer implements IClientPlayer try { ParticleType particle = packetIn.getParticleType(); - this.clientWorldController.spawnEntityFX(particle, particle.getShouldIgnoreRange() | packetIn.isLongDistance(), packetIn.getXCoordinate(), packetIn.getYCoordinate(), packetIn.getZCoordinate(), d0, d2, d4, packetIn.getParticleArgs()); + this.world.spawnEntityFX(particle, particle.getShouldIgnoreRange() | packetIn.isLongDistance(), packetIn.getXCoordinate(), packetIn.getYCoordinate(), packetIn.getZCoordinate(), d0, d2, d4, packetIn.getParticleArgs()); } catch (Throwable var17) { @@ -1861,17 +1836,17 @@ public class ClientPlayer implements IClientPlayer { for (int i = 0; i < packetIn.getParticleCount(); ++i) { - double d1 = this.avRandomizer.gaussian() * (double)packetIn.getXOffset(); - double d3 = this.avRandomizer.gaussian() * (double)packetIn.getYOffset(); - double d5 = this.avRandomizer.gaussian() * (double)packetIn.getZOffset(); - double d6 = this.avRandomizer.gaussian() * (double)packetIn.getParticleSpeed(); - double d7 = this.avRandomizer.gaussian() * (double)packetIn.getParticleSpeed(); - double d8 = this.avRandomizer.gaussian() * (double)packetIn.getParticleSpeed(); + double d1 = this.rand.gaussian() * (double)packetIn.getXOffset(); + double d3 = this.rand.gaussian() * (double)packetIn.getYOffset(); + double d5 = this.rand.gaussian() * (double)packetIn.getZOffset(); + double d6 = this.rand.gaussian() * (double)packetIn.getParticleSpeed(); + double d7 = this.rand.gaussian() * (double)packetIn.getParticleSpeed(); + double d8 = this.rand.gaussian() * (double)packetIn.getParticleSpeed(); try { ParticleType particle = packetIn.getParticleType(); - this.clientWorldController.spawnEntityFX(particle, particle.getShouldIgnoreRange() | packetIn.isLongDistance(), packetIn.getXCoordinate() + d1, packetIn.getYCoordinate() + d3, packetIn.getZCoordinate() + d5, d6, d7, d8, packetIn.getParticleArgs()); + this.world.spawnEntityFX(particle, particle.getShouldIgnoreRange() | packetIn.isLongDistance(), packetIn.getXCoordinate() + d1, packetIn.getYCoordinate() + d3, packetIn.getZCoordinate() + d5, d6, d7, d8, packetIn.getParticleArgs()); } catch (Throwable var16) { @@ -1889,8 +1864,8 @@ public class ClientPlayer implements IClientPlayer */ public void handleEntityProperties(SPacketEntityProperties packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); - Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId()); + NetHandler.checkThread(packetIn, this, this.gm, this.world); + Entity entity = this.world.getEntityByID(packetIn.getEntityId()); if (entity != null) { @@ -1924,9 +1899,9 @@ public class ClientPlayer implements IClientPlayer } public void handleSkin(SPacketSkin packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); + NetHandler.checkThread(packetIn, this, this.gm, this.world); - Entity entity = packetIn.getEntity(this.clientWorldController); + Entity entity = packetIn.getEntity(this.world); if(entity != null && entity.isPlayer()) // { EntityTexManager.setTexture(entity.getId(), packetIn.getTexture(), ((EntityNPC)entity).getModel()); // if(entity == this.gameController.thePlayer) @@ -1951,14 +1926,14 @@ public class ClientPlayer implements IClientPlayer // } public void handleTrades(SPacketTrades packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); + NetHandler.checkThread(packetIn, this, this.gm, this.world); try { int i = packetIn.getWindowId(); - Gui gui = this.gameController.open; + Gui gui = this.gm.open; - if (gui != null && gui instanceof GuiMerchant && i == this.gameController.player.openContainer.windowId) + if (gui != null && gui instanceof GuiMerchant && i == this.gm.player.openContainer.windowId) { // NpcMerchant imerchant = ((GuiMerchant)guiscreen).getMerchant(); MerchantRecipeList merchantrecipelist = packetIn.getTrades(); @@ -1972,45 +1947,17 @@ public class ClientPlayer implements IClientPlayer } public void handleWorld(SPacketWorld packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); - this.clientWorldController.setGravity(this.gameController.gravity = packetIn.getGravity()); - this.clientWorldController.setTimeFactor(this.gameController.timeFactor = packetIn.getTimeFactor()); + NetHandler.checkThread(packetIn, this, this.gm, this.world); + this.world.setGravity(this.gm.gravity = packetIn.getGravity()); + this.world.setTimeFactor(this.gm.timeFactor = packetIn.getTimeFactor()); // this.clientWorldController.setDifficulty(this.gameController.difficulty = packetIn.getDifficulty()); - this.gameController.dayCycle = packetIn.hasDayCycle(); + this.gm.dayCycle = packetIn.hasDayCycle(); } public void handleDimName(SPacketDimensionName packetIn) { - NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); - this.clientWorldController.dimension.setFullName(packetIn.getFullName()); - this.clientWorldController.dimension.setCustomName(packetIn.getCustomName()); - } - - /** - * Returns this the NetworkManager instance registered with this NetworkHandlerPlayClient - */ - public NetConnection getNetworkManager() - { - return this.netManager; - } - - public Set> getPlayerList() - { - return this.playerList.entrySet(); - } - - public Collection getCharacterList() - { - return this.characterList; - } - - public int getSelectedCharacter() - { - return this.selectedCharacter; - } - - public Iterable getPlayerNames() - { - return this.playerList.keySet(); + NetHandler.checkThread(packetIn, this, this.gm, this.world); + this.world.dimension.setFullName(packetIn.getFullName()); + this.world.dimension.setCustomName(packetIn.getCustomName()); } public void displayGUIChest(IInventory chestInventory, InventoryPlayer inventory) { @@ -2018,19 +1965,19 @@ public class ClientPlayer implements IClientPlayer if ("chest".equals(s)) { - this.gameController.displayGuiScreen(new GuiChest(inventory, chestInventory)); + this.gm.displayGuiScreen(new GuiChest(inventory, chestInventory)); } else if ("hopper".equals(s)) { - this.gameController.displayGuiScreen(new GuiHopper(inventory, chestInventory)); + this.gm.displayGuiScreen(new GuiHopper(inventory, chestInventory)); } else if ("furnace".equals(s)) { - this.gameController.displayGuiScreen(new GuiFurnace(inventory, chestInventory)); + this.gm.displayGuiScreen(new GuiFurnace(inventory, chestInventory)); } else if ("brewing_stand".equals(s)) { - this.gameController.displayGuiScreen(new GuiBrewing(inventory, chestInventory)); + this.gm.displayGuiScreen(new GuiBrewing(inventory, chestInventory)); } // else if ("beacon".equals(s)) // { @@ -2038,11 +1985,11 @@ public class ClientPlayer implements IClientPlayer // } else if (!"dispenser".equals(s) && !"dropper".equals(s)) { - this.gameController.displayGuiScreen(new GuiChest(inventory, chestInventory)); + this.gm.displayGuiScreen(new GuiChest(inventory, chestInventory)); } else { - this.gameController.displayGuiScreen(new GuiDispenser(inventory, chestInventory)); + this.gm.displayGuiScreen(new GuiDispenser(inventory, chestInventory)); } } @@ -2051,31 +1998,27 @@ public class ClientPlayer implements IClientPlayer Block block = BlockRegistry.getRegisteredBlock(s); if(block instanceof BlockWorkbench) { - this.gameController.displayGuiScreen(new GuiCrafting(inventory, worldObj, (BlockWorkbench)block)); + this.gm.displayGuiScreen(new GuiCrafting(inventory, worldObj, (BlockWorkbench)block)); } else if ("enchanting_table".equals(s)) { - this.gameController.displayGuiScreen(new GuiEnchant(inventory, worldObj, guiOwner)); + this.gm.displayGuiScreen(new GuiEnchant(inventory, worldObj, guiOwner)); } else if ("anvil".equals(s)) { - this.gameController.displayGuiScreen(new GuiRepair(inventory, worldObj)); + this.gm.displayGuiScreen(new GuiRepair(inventory, worldObj)); } } public void displayGuiHorse(EntityHorse horse, InventoryPlayer inventory, IInventory horseInventory) { - this.gameController.displayGuiScreen(new GuiHorse(inventory, horseInventory, horse)); + this.gm.displayGuiScreen(new GuiHorse(inventory, horseInventory, horse)); } public void displayGuiMerchant(String title, InventoryPlayer inventory, World worldObj) { - this.gameController.displayGuiScreen(new GuiMerchant(inventory, title, worldObj)); + this.gm.displayGuiScreen(new GuiMerchant(inventory, title, worldObj)); } public void displayGuiSign(BlockPos pos, String[] text) { - this.gameController.displayGuiScreen(new GuiSign(pos, text)); - } - - public void closeGui() { - this.gameController.displayGuiScreen(null); + this.gm.displayGuiScreen(new GuiSign(pos, text)); } } diff --git a/client/src/main/java/client/network/DummyConnection.java b/client/src/main/java/client/network/DummyConnection.java new file mode 100644 index 0000000..b9f6323 --- /dev/null +++ b/client/src/main/java/client/network/DummyConnection.java @@ -0,0 +1,67 @@ +package client.network; + +import javax.crypto.SecretKey; + +import common.net.channel.ChannelHandlerContext; +import common.net.util.concurrent.Future; +import common.net.util.concurrent.GenericFutureListener; +import common.network.NetConnection; +import common.network.NetHandler; +import common.network.Packet; +import common.network.PacketRegistry; + +public class DummyConnection extends NetConnection { + public void channelActive(ChannelHandlerContext context) throws Exception { + } + + public void setConnectionState(PacketRegistry newState) { + } + + public void channelInactive(ChannelHandlerContext context) throws Exception { + } + + public void exceptionCaught(ChannelHandlerContext context, Throwable throwable) throws Exception { + } + + protected void channelRead0(ChannelHandlerContext context, Packet packet) throws Exception { + } + + public void setNetHandler(NetHandler handler) { + } + + public void sendPacket(Packet packet) { + } + + public void sendPacket(Packet packet, GenericFutureListener> listener) { + } + + public void processReceivedPackets() { + } + + public String getCutAddress() { + return "local"; + } + + public void closeChannel(String message) { + } + + public boolean isChannelOpen() { + return true; + } + + public boolean hasNoChannel() { + return false; + } + + public void disableAutoRead() { + } + + public void setCompressionTreshold(int treshold) { + } + + public void checkDisconnected() { + } + + public void startEncryption(SecretKey key) { + } +} diff --git a/client/src/main/java/client/network/DummyPlayer.java b/client/src/main/java/client/network/DummyPlayer.java new file mode 100644 index 0000000..ab5be6a --- /dev/null +++ b/client/src/main/java/client/network/DummyPlayer.java @@ -0,0 +1,321 @@ +package client.network; + +import client.Client; +import client.util.DummyController; +import client.world.WorldClient; +import common.dimension.Space; +import common.entity.Entity; +import common.entity.animal.EntityHorse; +import common.entity.npc.EntityCpu; +import common.init.EntityRegistry; +import common.inventory.IInventory; +import common.inventory.InventoryPlayer; +import common.model.ParticleType; +import common.network.Packet; +import common.packet.SPacketEntity; +import common.packet.SPacketEntityTeleport; +import common.packet.SPacketEntityHeadLook; +import common.packet.SPacketEntityStatus; +import common.packet.SPacketEntityAttach; +import common.packet.SPacketEntityMetadata; +import common.packet.SPacketEntityEffect; +import common.packet.SPacketRemoveEntityEffect; +import common.packet.SPacketEntityProperties; +import common.packet.SPacketExplosion; +import common.packet.SPacketEffect; +import common.packet.SPacketSoundEffect; +import common.packet.SPacketParticles; +import common.packet.SPacketChangeGameState; +import common.packet.SPacketSpawnGlobalEntity; +import common.packet.SPacketOpenWindow; +import common.packet.SPacketCloseWindow; +import common.packet.SPacketSetSlot; +import common.packet.SPacketWindowItems; +import common.packet.SPacketWindowProperty; +import common.packet.SPacketConfirmTransaction; +import common.packet.SPacketUpdateSign; +import common.packet.SPacketUpdateTileEntity; +import common.packet.SPacketSignEditorOpen; +import common.packet.SPacketPlayerListItem; +import common.packet.SPacketPlayerAbilities; +import common.packet.SPacketTabComplete; +import common.packet.SPacketUpdateEntityTags; +import common.packet.SPacketAnimation; +import common.packet.SPacketBiome; +import common.packet.SPacketBlockAction; +import common.packet.SPacketBlockBreakAnim; +import common.packet.SPacketBlockChange; +import common.packet.SPacketCamera; +import common.packet.SPacketCharacterList; +import common.packet.SPacketChunkData; +import common.packet.SPacketCollectItem; +import common.packet.SPacketDestroyEntities; +import common.packet.SPacketDimensionName; +import common.packet.SPacketDisconnect; +import common.packet.SPacketDisplayForm; +import common.packet.SPacketEntityEquipment; +import common.packet.SPacketEntityVelocity; +import common.packet.SPacketHeldItemChange; +import common.packet.SPacketJoinGame; +import common.packet.SPacketKeepAlive; +import common.packet.SPacketLoading; +import common.packet.SPacketMapChunkBulk; +import common.packet.SPacketMessage; +import common.packet.SPacketMultiBlockChange; +import common.packet.SPacketPlayerPosLook; +import common.packet.SPacketRespawn; +import common.packet.SPacketServerTick; +import common.packet.SPacketSetExperience; +import common.packet.SPacketSkin; +import common.packet.SPacketSpawnMob; +import common.packet.SPacketSpawnObject; +import common.packet.SPacketSpawnPlayer; +import common.packet.SPacketTimeUpdate; +import common.packet.SPacketTrades; +import common.packet.SPacketUpdateHealth; +import common.packet.SPacketWorld; +import common.potion.Potion; +import common.potion.PotionEffect; +import common.sound.Sound; +import common.tileentity.IInteractionObject; +import common.util.BlockPos; +import common.world.World; + +public class DummyPlayer extends ClientPlayer { + public DummyPlayer(Client gm) { + super(gm, new DummyConnection()); + } + + public void join() { + this.gm.noResolve = true; + this.gm.charEditor = false; + this.gm.controller = new DummyController(this); + WorldClient world = new WorldClient(this.gm, true, Space.INSTANCE); + this.gm.loadWorld(world, EntityRegistry.getEntityID(EntityCpu.class)); + this.gm.player.setId(0); + this.gm.displayGuiScreen(null); + this.gm.player.flying = true; + this.gm.player.noclip = true; + this.gm.player.addEffect(new PotionEffect(Potion.FLYING, Integer.MAX_VALUE, 1)); + this.gm.player.setHeight(2.0f); + world.setGravity(this.gm.gravity = 1.0f); + world.setTimeFactor(this.gm.timeFactor = 1); + this.gm.dayCycle = true; + } + + public void cleanup() { + } + + public void playSound(Sound sound) { + } + + public void emitParticleAtEntity(Entity entityIn, ParticleType particleTypes) { + } + + public void displayGUIChest(IInventory chestInventory, InventoryPlayer inventory) { + } + + public void displayGui(IInteractionObject guiOwner, InventoryPlayer inventory, World worldObj) { + } + + public void displayGuiHorse(EntityHorse horse, InventoryPlayer inventory, IInventory horseInventory) { + } + + public void displayGuiMerchant(String title, InventoryPlayer inventory, World worldObj) { + } + + public void displayGuiSign(BlockPos pos, String[] text) { + } + + public void onDisconnect(String reason) { + } + + public void addToSendQueue(Packet packet) { + } + + public void handleJoinGame(SPacketJoinGame packetIn) { + } + + public void handleSpawnObject(SPacketSpawnObject packetIn) { + } + + public void handleSpawnGlobalEntity(SPacketSpawnGlobalEntity packetIn) { + } + + public void handleEntityVelocity(SPacketEntityVelocity packetIn) { + } + + public void handleEntityMetadata(SPacketEntityMetadata packetIn) { + } + + public void handleSpawnPlayer(SPacketSpawnPlayer packetIn) { + } + + public void handleEntityTeleport(SPacketEntityTeleport packetIn) { + } + + public void handleHeldItemChange(SPacketHeldItemChange packetIn) { + } + + public void handleEntityMovement(SPacketEntity packetIn) { + } + + public void handleEntityHeadLook(SPacketEntityHeadLook packetIn) { + } + + public void handleDestroyEntities(SPacketDestroyEntities packetIn) { + } + + public void handlePlayerPosLook(SPacketPlayerPosLook packetIn) { + } + + public void handleMultiBlockChange(SPacketMultiBlockChange packetIn) { + } + + public void handleChunkData(SPacketChunkData packetIn) { + } + + public void handleBiomes(SPacketBiome packetIn) { + } + + public void handleBlockChange(SPacketBlockChange packetIn) { + } + + public void handleDisconnect(SPacketDisconnect packetIn) { + } + + public void handleCollectItem(SPacketCollectItem packetIn) { + } + + public void handleMessage(SPacketMessage packetIn) { + } + + public void handleLoading(SPacketLoading packet) { + } + + public void handleAnimation(SPacketAnimation packetIn) { + } + + public void handleSpawnMob(SPacketSpawnMob packetIn) { + } + + public void handleTimeUpdate(SPacketTimeUpdate packetIn) { + } + + public void handleServerTick(SPacketServerTick packet) { + } + + public void handleEntityAttach(SPacketEntityAttach packetIn) { + } + + public void handleEntityStatus(SPacketEntityStatus packetIn) { + } + + public void handleUpdateHealth(SPacketUpdateHealth packetIn) { + } + + public void handleSetExperience(SPacketSetExperience packetIn) { + } + + public void handleRespawn(SPacketRespawn packetIn) { + } + + public void handleExplosion(SPacketExplosion packetIn) { + } + + public void handleOpenWindow(SPacketOpenWindow packetIn) { + } + + public void handleSetSlot(SPacketSetSlot packetIn) { + } + + public void handleConfirmTransaction(SPacketConfirmTransaction packetIn) { + } + + public void handleWindowItems(SPacketWindowItems packetIn) { + } + + public void handleSignEditorOpen(SPacketSignEditorOpen packetIn) { + } + + public void handleForm(SPacketDisplayForm packet) { + } + + public void handleUpdateSign(SPacketUpdateSign packetIn) { + } + + public void handleUpdateTileEntity(SPacketUpdateTileEntity packetIn) { + } + + public void handleWindowProperty(SPacketWindowProperty packetIn) { + } + + public void handleEntityEquipment(SPacketEntityEquipment packetIn) { + } + + public void handleCloseWindow(SPacketCloseWindow packetIn) { + } + + public void handleBlockAction(SPacketBlockAction packetIn) { + } + + public void handleBlockBreakAnim(SPacketBlockBreakAnim packetIn) { + } + + public void handleMapChunkBulk(SPacketMapChunkBulk packetIn) { + } + + public void handleChangeGameState(SPacketChangeGameState packetIn) { + } + + public void handleEffect(SPacketEffect packetIn) { + } + + public void handleEntityEffect(SPacketEntityEffect packetIn) { + } + + public void handleCamera(SPacketCamera packetIn) { + } + + public void handleRemoveEntityEffect(SPacketRemoveEntityEffect packetIn) { + } + + public void handlePlayerListItem(SPacketPlayerListItem packetIn) { + } + + public void handleCharacterList(SPacketCharacterList packet) { + } + + public void handleKeepAlive(SPacketKeepAlive packetIn) { + } + + public void handlePlayerAbilities(SPacketPlayerAbilities packetIn) { + } + + public void handleTabComplete(SPacketTabComplete packetIn) { + } + + public void handleSoundEffect(SPacketSoundEffect packetIn) { + } + + public void handleEntityTags(SPacketUpdateEntityTags packetIn) { + } + + public void handleParticles(SPacketParticles packetIn) { + } + + public void handleEntityProperties(SPacketEntityProperties packetIn) { + } + + public void handleSkin(SPacketSkin packetIn) { + } + + public void handleTrades(SPacketTrades packetIn) { + } + + public void handleWorld(SPacketWorld packetIn) { + } + + public void handleDimName(SPacketDimensionName packetIn) { + } +} diff --git a/client/src/main/java/client/renderer/BlockRenderer.java b/client/src/main/java/client/renderer/BlockRenderer.java index 70838df..51961b1 100755 --- a/client/src/main/java/client/renderer/BlockRenderer.java +++ b/client/src/main/java/client/renderer/BlockRenderer.java @@ -96,7 +96,7 @@ public class BlockRenderer { Block block = state.getBlock(); - if (!this.gm.debugWorld) + if (!this.gm.noResolve) { try { diff --git a/client/src/main/java/client/util/DummyController.java b/client/src/main/java/client/util/DummyController.java new file mode 100644 index 0000000..25d461f --- /dev/null +++ b/client/src/main/java/client/util/DummyController.java @@ -0,0 +1,77 @@ +package client.util; + +import client.network.DummyPlayer; +import client.world.WorldClient; +import common.entity.Entity; +import common.entity.npc.EntityNPC; +import common.init.EntityRegistry; +import common.item.ItemStack; +import common.util.BlockPos; +import common.util.Facing; +import common.util.Vec3; +import common.world.World; + +public class DummyController extends PlayerController { + private final DummyPlayer player; + + public DummyController(DummyPlayer player) { + super(null, null); + this.player = player; + } + + public boolean destroyBlock(BlockPos pos, Facing side) { + return false; + } + + public boolean clickBlock(BlockPos pos, Facing face) { + return false; + } + + public void resetProgress() { + } + + public void resetInteraction() { + } + + public boolean damageBlock(BlockPos pos, Facing face) { + return false; + } + + public void update() { + } + + public boolean clickRight(EntityNPC player, WorldClient world, ItemStack stack, BlockPos pos, Facing side, Vec3 hit) { + return false; + } + + public boolean sendUseItem(EntityNPC player, World world, ItemStack stack) { + return false; + } + + public EntityNPC createPlayerEntity(WorldClient world, int type) { + EntityNPC player = (EntityNPC)EntityRegistry.createEntityByID(type, world); + player.setClientPlayer(this.player); + return player; + } + + public void attackEntity(EntityNPC player, Entity target) { + } + + public boolean interact(EntityNPC player, Entity target) { + return false; + } + + public ItemStack windowClick(int window, int slot, int button, int mode, EntityNPC player) { + return null; + } + + public void sendEnchantPacket(int window, int button) { + } + + public void stopUsing(EntityNPC player) { + } + + public boolean isHittingBlock() { + return false; + } +} diff --git a/client/src/main/java/client/util/PlayerController.java b/client/src/main/java/client/util/PlayerController.java index 56812bc..e18d64f 100755 --- a/client/src/main/java/client/util/PlayerController.java +++ b/client/src/main/java/client/util/PlayerController.java @@ -175,11 +175,11 @@ public class PlayerController { public void update() { this.syncItem(); - if(this.handler.getNetworkManager().isChannelOpen()) { - this.handler.getNetworkManager().processReceivedPackets(); + if(this.handler.getConnection().isChannelOpen()) { + this.handler.getConnection().processReceivedPackets(); } else { - this.handler.getNetworkManager().checkDisconnected(); + this.handler.getConnection().checkDisconnected(); } } diff --git a/client/src/main/java/client/world/ChunkEmpty.java b/client/src/main/java/client/world/ChunkEmpty.java index 1b03600..dce55fe 100755 --- a/client/src/main/java/client/world/ChunkEmpty.java +++ b/client/src/main/java/client/world/ChunkEmpty.java @@ -5,24 +5,60 @@ import java.util.function.Predicate; import common.biome.Biome; import common.block.Block; +import common.collect.Lists; import common.entity.Entity; +import common.init.BlockRegistry; import common.init.Blocks; import common.tileentity.TileEntity; import common.util.BlockPos; import common.util.BoundingBox; +import common.util.ExtMath; import common.world.LightType; import common.world.State; public class ChunkEmpty extends ChunkClient { + private static final List STATES = Lists.newArrayList(); + private static final int XSTRETCH; + private static final int ZSTRETCH; + + private final boolean debug; private final int liquidY; private final State liquid; private final Block liquidBlock; + private final State dummy; + private final Block dummyBlock; - public ChunkEmpty(WorldClient world) { + static { + for(Block block : BlockRegistry.REGISTRY) { + STATES.addAll(block.getValidStates()); + } + XSTRETCH = ExtMath.ceilf(ExtMath.sqrtf((float)STATES.size())); + ZSTRETCH = ExtMath.ceilf((float)STATES.size() / (float)XSTRETCH); + } + + private static State getDebug(int x, int z) { + State state = null; + if(x > 0 && z > 0 && x % 2 != 0 && z % 2 != 0) { + x = x / 2; + z = z / 2; + if(x <= XSTRETCH && z <= ZSTRETCH) { + int idx = ExtMath.absi(x * XSTRETCH + z); + if(idx < STATES.size()) { + state = STATES.get(idx); + } + } + } + return state; + } + + public ChunkEmpty(WorldClient world, boolean debug) { super(world, 0, 0); + this.debug = debug; this.liquidY = world.dimension.getSeaLevel() - 1; this.liquid = world.dimension.getLiquid(); this.liquidBlock = this.liquid.getBlock(); + this.dummyBlock = this.fillerBlock == Blocks.air ? Blocks.air : Blocks.bedrock; + this.dummy = this.dummyBlock.getState(); } public int getHeight(int x, int z) { @@ -30,7 +66,7 @@ public class ChunkEmpty extends ChunkClient { } public Block getBlock(BlockPos pos) { - return pos.getY() < this.liquidY ? Blocks.bedrock : (pos.getY() == this.liquidY ? this.liquidBlock : Blocks.air); + return pos.getY() < this.liquidY ? this.dummyBlock : (pos.getY() == this.liquidY ? this.liquidBlock : Blocks.air); } public int getLight(LightType type, BlockPos pos) { @@ -79,7 +115,11 @@ public class ChunkEmpty extends ChunkClient { } public State getState(BlockPos pos) { - return pos.getY() < this.liquidY ? Blocks.bedrock.getState() : (pos.getY() == this.liquidY ? this.liquid : Blocks.air.getState()); + if(this.debug) { + State state = pos.getY() == 1 ? getDebug(pos.getX(), pos.getZ()) : null; + return state == null ? Blocks.air.getState() : state; + } + return pos.getY() < this.liquidY ? this.dummy : (pos.getY() == this.liquidY ? this.liquid : Blocks.air.getState()); } public State setState(BlockPos pos, State state) { diff --git a/client/src/main/java/client/world/WorldClient.java b/client/src/main/java/client/world/WorldClient.java index a704d32..ae36ef7 100755 --- a/client/src/main/java/client/world/WorldClient.java +++ b/client/src/main/java/client/world/WorldClient.java @@ -42,6 +42,7 @@ public class WorldClient extends AWorldClient private static final int DISPLAY_RANGE = 16; private final Client gm; + private final ChunkClient emptyChunk; private final Set entityList = Sets.newHashSet(); private final Set spawnQueue = Sets.newHashSet(); private final Set previousActive = Sets.newHashSet(); @@ -49,15 +50,15 @@ public class WorldClient extends AWorldClient private final List chunkListing = Lists.newArrayList(); private final Set emptyChunkListing = Sets.newHashSet(); private final Set nextEmptyChunkListing = Sets.newHashSet(); - private final ChunkClient emptyChunk = new ChunkEmpty(this); // public final Profiler profiler; protected int lastLightning; protected Vec3 lightColor = new Vec3(0xffffff); public WorldClient(Client gm, boolean debug, Dimension dim) { - super(dim, debug); + super(dim); this.gm = gm; + this.emptyChunk = new ChunkEmpty(this, debug); this.calculateInitialSkylight(); this.calculateInitialWeather(); this.setGravity(this.gm.gravity); diff --git a/common/src/main/java/common/packet/RPacketLoginSuccess.java b/common/src/main/java/common/packet/RPacketLoginSuccess.java index a8b7837..0869607 100755 --- a/common/src/main/java/common/packet/RPacketLoginSuccess.java +++ b/common/src/main/java/common/packet/RPacketLoginSuccess.java @@ -7,28 +7,16 @@ import common.network.Packet; import common.network.PacketBuffer; public class RPacketLoginSuccess implements Packet { - private boolean debug; - public RPacketLoginSuccess() { } - public RPacketLoginSuccess(boolean debug) { - this.debug = debug; - } - public final void readPacketData(PacketBuffer buf) throws IOException { - this.debug = buf.readBoolean(); } public final void writePacketData(PacketBuffer buf) throws IOException { - buf.writeBoolean(this.debug); } public void processPacket(IClientLoginHandler handler) { handler.handleLoginSuccess(this); } - - public boolean isDebug() { - return this.debug; - } } diff --git a/common/src/main/java/common/world/AWorldClient.java b/common/src/main/java/common/world/AWorldClient.java index 32a595f..3b12d01 100644 --- a/common/src/main/java/common/world/AWorldClient.java +++ b/common/src/main/java/common/world/AWorldClient.java @@ -5,8 +5,8 @@ import common.init.SoundEvent; import common.tags.TagObject; public abstract class AWorldClient extends World { - protected AWorldClient(Dimension dim, boolean debug) { - super(dim, true, debug); + protected AWorldClient(Dimension dim) { + super(dim, true); } public abstract void playSound(double x, double y, double z, SoundEvent sound, float volume); diff --git a/common/src/main/java/common/world/AWorldServer.java b/common/src/main/java/common/world/AWorldServer.java index 3ca91f0..e91f4ec 100644 --- a/common/src/main/java/common/world/AWorldServer.java +++ b/common/src/main/java/common/world/AWorldServer.java @@ -17,8 +17,8 @@ import common.util.PortalType; import common.village.Village; public abstract class AWorldServer extends World { - protected AWorldServer(Dimension dim, boolean debug) { - super(dim, false, debug); + protected AWorldServer(Dimension dim) { + super(dim, false); } public abstract List getAllPlayers(); diff --git a/common/src/main/java/common/world/Chunk.java b/common/src/main/java/common/world/Chunk.java index 2f05337..d86700b 100755 --- a/common/src/main/java/common/world/Chunk.java +++ b/common/src/main/java/common/world/Chunk.java @@ -300,11 +300,6 @@ public abstract class Chunk { } public State getState(BlockPos pos) { - if(this.world.debug) { - State state = pos.getY() == 1 ? DebugStates.getState(pos.getX(), pos.getZ()) : null; - return state == null ? Blocks.air.getState() : state; - } - BlockArray stor = this.getArray(pos.getY() >> 4); return stor != null ? stor.get(pos.getX() & 15, pos.getY() & 15, pos.getZ() & 15) : (pos.getY() < 0 ? this.filler : Blocks.air.getState()); } diff --git a/common/src/main/java/common/world/DebugStates.java b/common/src/main/java/common/world/DebugStates.java deleted file mode 100644 index a569464..0000000 --- a/common/src/main/java/common/world/DebugStates.java +++ /dev/null @@ -1,37 +0,0 @@ -package common.world; - -import java.util.List; - -import common.block.Block; -import common.collect.Lists; -import common.init.BlockRegistry; -import common.util.ExtMath; - -public class DebugStates { - private static final List STATES = Lists.newArrayList(); - private static final int XSTRETCH; - private static final int ZSTRETCH; - - static { - for(Block block : BlockRegistry.REGISTRY) { - STATES.addAll(block.getValidStates()); - } - XSTRETCH = ExtMath.ceilf(ExtMath.sqrtf((float)STATES.size())); - ZSTRETCH = ExtMath.ceilf((float)STATES.size() / (float)XSTRETCH); - } - - public static State getState(int x, int z) { - State state = null; - if(x > 0 && z > 0 && x % 2 != 0 && z % 2 != 0) { - x = x / 2; - z = z / 2; - if(x <= XSTRETCH && z <= ZSTRETCH) { - int idx = ExtMath.absi(x * XSTRETCH + z); - if(idx < STATES.size()) { - state = STATES.get(idx); - } - } - } - return state; - } -} diff --git a/common/src/main/java/common/world/World.java b/common/src/main/java/common/world/World.java index 6bd37b7..c2c668b 100755 --- a/common/src/main/java/common/world/World.java +++ b/common/src/main/java/common/world/World.java @@ -58,7 +58,6 @@ public abstract class World implements IWorldAccess { // private static long lastUpdate; public final boolean client; - public final boolean debug; public double gravity = 1.0; protected long timeFactor = 1L; public final Random rand = new Random(); @@ -116,14 +115,13 @@ public abstract class World implements IWorldAccess { return pos.getX() >= -MAX_SIZE && pos.getZ() >= -MAX_SIZE && pos.getX() < MAX_SIZE && pos.getZ() < MAX_SIZE; } - protected World(Dimension dim, boolean client, boolean debug) { + protected World(Dimension dim, boolean client) { // this.profiler = profiler; // this.info = info; // this.dimInfo = info.getDimension(dim.getDimensionId()); this.dimension = dim; // this.storage = storage; this.client = client; - this.debug = debug; this.weather = dim.getWeather(); } @@ -200,9 +198,6 @@ public abstract class World implements IWorldAccess { if(!isValid(pos)) { return false; } - else if(!this.client && this.debug) { - return false; - } else { Chunk chunk = this.getChunk(pos); Block block = newState.getBlock(); @@ -225,7 +220,7 @@ public abstract class World implements IWorldAccess { } if(!this.client && (flags & 1) != 0) { - this.notifyNeighborsRespectDebug(pos, iblockstate.getBlock()); + this.notifyNeighborsOfStateChange(pos, iblockstate.getBlock()); if(block.hasComparatorInputOverride()) { this.updateComparatorOutputLevel(pos, block); @@ -263,12 +258,6 @@ public abstract class World implements IWorldAccess { } } - public void notifyNeighborsRespectDebug(BlockPos pos, Block blockType) { - if(!this.debug) { - this.notifyNeighborsOfStateChange(pos, blockType); - } - } - public void markBlocksDirtyVertical(int x1, int z1, int x2, int z2) { if(x2 > z2) { int i = z2; diff --git a/server/src/main/java/server/Server.java b/server/src/main/java/server/Server.java index c88c334..8ca0888 100755 --- a/server/src/main/java/server/Server.java +++ b/server/src/main/java/server/Server.java @@ -121,7 +121,6 @@ public final class Server implements IThreadListener { private final List unload = Lists.newArrayList(); private final Map warps = Maps.newTreeMap(); private final CommandEnvironment scriptEnv = new CommandEnvironment(this); - private final boolean debug; private KeyPair keyPair; private WorldServer space; @@ -158,8 +157,7 @@ public final class Server implements IThreadListener { UniverseRegistry.register(); RotationRegistry.register(); ReorderRegistry.register(); - boolean debug = System.getProperty("server.debug", null) != null; - final Server server = new Server(debug); + final Server server = new Server(); Registry.addShutdownHook(new Runnable() { public void run() { server.stopServer(); @@ -240,8 +238,7 @@ public final class Server implements IThreadListener { return World.START_TIME; } - private Server(boolean debug) { - this.debug = debug; + private Server() { Config.setCallback(new Runnable() { public void run() { for(WorldServer world : Server.this.getWorlds()) { @@ -277,7 +274,7 @@ public final class Server implements IThreadListener { } public List getPlayerFilenames() { - String[] list = this.debug ? null : new File("players").list(); + String[] list = new File("players").list(); if(list == null) return Lists.newArrayList(); List names = Lists.newArrayList(); @@ -292,14 +289,12 @@ public final class Server implements IThreadListener { } public void saveWorldInfo() { - if(!this.debug) { - saveServerConfig(this.space.getDayTime(), this); - WorldServer.saveWarps(this.warps); - } + saveServerConfig(this.space.getDayTime(), this); + WorldServer.saveWarps(this.warps); } public TagObject loadPlayerData(String user) { - if(this.debug || !IPlayer.isValidUser(user)) + if(!IPlayer.isValidUser(user)) return null; TagObject tag = null; try { @@ -316,7 +311,7 @@ public final class Server implements IThreadListener { } public void writePlayerData(String user, TagObject tag) { - if(this.debug || !IPlayer.isValidUser(user)) + if(!IPlayer.isValidUser(user)) return; try { File tmp = new File(new File("players"), user + ".cdt.tmp"); @@ -346,8 +341,6 @@ public final class Server implements IThreadListener { } public void saveAllWorlds(boolean message) { - if(this.debug) - return; if(message) Log.TICK.info("Speichere Welt"); this.saveWorldInfo(); @@ -372,22 +365,20 @@ public final class Server implements IThreadListener { } public void run(long time) { - if(!this.debug) { - Converter.convert(); - long wtime = this.loadServerConfig(); - if(this.keyPair == null) { - Log.SYSTEM.info("Generiere neues Schlüsselpaar"); - this.keyPair = EncryptUtil.createKeypair(); - } - User.loadDatabase(this.users); + Converter.convert(); + long wtime = this.loadServerConfig(); + if(this.keyPair == null) { + Log.SYSTEM.info("Generiere neues Schlüsselpaar"); + this.keyPair = EncryptUtil.createKeypair(); + } + User.loadDatabase(this.users); // if(dtime == -1L) // { // dtime = World.START_TIME; //// Config.set("spawnDim", "1", null); //// } - this.worlds.add(this.space = new WorldServer(this, wtime, - Space.INSTANCE, false)); - this.dimensions.put(this.space.dimension.getDimensionId(), this.space); - new File("players").mkdirs(); + this.worlds.add(this.space = new WorldServer(this, wtime, Space.INSTANCE)); + this.dimensions.put(this.space.dimension.getDimensionId(), this.space); + new File("players").mkdirs(); // if(Config.spawnY < 0) { // WorldServer world = this.getWorld(Config.spawnDim); // world = world == null ? this.space : world; @@ -410,28 +401,12 @@ public final class Server implements IThreadListener { // Config.set("spawnYaw", "" + (-180.0f + rand.floatv() * 360.0f), null); // Config.set("spawnPitch", "0.0", null); // } - } - else { - Log.SYSTEM.info("Generiere temporäres Schlüsselpaar"); - this.keyPair = EncryptUtil.createKeypair(); - Config.clear(); - UniverseRegistry.clear(); - Config.set("daylightCycle", "false", false); - Config.set("weatherChanges", "false", false); - Config.set("mobSpawning", "false", false); - Config.set("spawnRadius", "0", false); - this.worlds.add(this.space = new WorldServer(this, World.START_TIME, - Space.INSTANCE, true)); - this.dimensions.put(this.space.dimension.getDimensionId(), this.space); - } this.setTpsTarget(20.0f); - if(!this.debug) { - for(Dimension dim : UniverseRegistry.getDimensions()) { - if(WorldServer.needsLoading(dim)) { - this.getWorld(dim.getDimensionId()).loadForcedChunks(); - } - WorldServer.loadWarps(dim, this.warps); + for(Dimension dim : UniverseRegistry.getDimensions()) { + if(WorldServer.needsLoading(dim)) { + this.getWorld(dim.getDimensionId()).loadForcedChunks(); } + WorldServer.loadWarps(dim, this.warps); } if(Config.port >= 0) this.bind(Config.port); @@ -626,8 +601,7 @@ public final class Server implements IThreadListener { Dimension dim = UniverseRegistry.getDimension(dimension); if(dim == null) return null; - world = new WorldServer(this, this.space.getDayTime(), - dim, this.debug); + world = new WorldServer(this, this.space.getDayTime(), dim); this.worlds.add(world); this.dimensions.put(dimension, world); } @@ -786,7 +760,7 @@ public final class Server implements IThreadListener { } }); } - connection.sendPacket(new RPacketLoginSuccess(this.debug)); + connection.sendPacket(new RPacketLoginSuccess()); connection.setNetHandler(conn); this.players.add(conn); User user = this.users.remove(loginUser); @@ -861,8 +835,6 @@ public final class Server implements IThreadListener { } private TagObject readPlayer(String user) { - if(this.debug) - return null; TagObject tag = null; try { File dat = new File(new File("players"), user + ".cdt"); @@ -878,8 +850,6 @@ public final class Server implements IThreadListener { } private void writePlayer(Player conn) { - if(this.debug) - return; try { TagObject tag = new TagObject(); EntityNPC entity = conn.getPresentEntity(); @@ -1107,8 +1077,6 @@ public final class Server implements IThreadListener { } public void saveAllPlayerData(boolean message) { - if(this.debug) - return; if(message) { Log.TICK.info("Speichere Spielerdaten"); } diff --git a/server/src/main/java/server/world/WorldServer.java b/server/src/main/java/server/world/WorldServer.java index a03eaef..4607c2b 100755 --- a/server/src/main/java/server/world/WorldServer.java +++ b/server/src/main/java/server/world/WorldServer.java @@ -93,7 +93,6 @@ import server.worldgen.FeatureLakes; import server.worldgen.FeatureLiquids; import server.worldgen.FeatureOres; import server.worldgen.GeneratorCavern; -import server.worldgen.GeneratorDebug; import server.worldgen.GeneratorDestroyed; import server.worldgen.GeneratorFlat; import server.worldgen.GeneratorIsland; @@ -283,78 +282,52 @@ public final class WorldServer extends AWorldServer { return gens; } - public WorldServer(Server server, long dtime, Dimension dim, boolean debug) { - super(dim, debug); + public WorldServer(Server server, long dtime, Dimension dim) { + super(dim); this.server = server; // this.time = time; this.daytime = dtime; this.updateViewRadius(); this.chunkDir = new File(new File("chunk"), dim.getDimensionName()); - if(!debug) { - this.chunkDir.mkdirs(); - if(!Config.seed.isEmpty()) - this.rand.setSeed((long)Config.seed.hashCode() ^ ~((long)dim.getDimensionName().hashCode())); - this.seed = this.rand.longv(); - this.dimension.setSeed(this.seed); - TagObject tag = null; - try { - File dat = new File(this.chunkDir, "data.cdt"); - if(dat.exists() && dat.isFile()) - tag = TagObject.readGZip(dat); - } - catch(Exception e) { - Log.IO.error(e, "Konnte Weltdaten nicht laden"); - } - if(tag != null) { - this.exterminated = tag.getBool("Exterminated"); - this.time = tag.getLong("Time"); - if(tag.hasObject("Generator")) { - this.dimension.fromTags(tag.getObject("Generator")); - if(this.dimension.getType().weather && !this.exterminated) - this.weather = this.dimension.getWeather(); - this.seed = this.dimension.getSeed(); - } - if(this.dimension.getType().weather && !this.exterminated) - this.weather = Weather.getByName(tag.getString("Weather")); - if(this.weather == null) { - this.weather = this.dimension.getWeather(); -// this.dataModified = true; - } - // ... - } - else { - Log.TICK.info("Startwert für %s: %d" + (Config.seed.isEmpty() ? "" : " von Basiswert '%s'"), this.dimension.getFormattedName(false), this.seed, Config.seed); - } - if(this.exterminated) - this.weather = Weather.CLEAR; + this.chunkDir.mkdirs(); + if(!Config.seed.isEmpty()) + this.rand.setSeed((long)Config.seed.hashCode() ^ ~((long)dim.getDimensionName().hashCode())); + this.seed = this.rand.longv(); + this.dimension.setSeed(this.seed); + TagObject tag = null; + try { + File dat = new File(this.chunkDir, "data.cdt"); + if(dat.exists() && dat.isFile()) + tag = TagObject.readGZip(dat); } + catch(Exception e) { + Log.IO.error(e, "Konnte Weltdaten nicht laden"); + } + if(tag != null) { + this.exterminated = tag.getBool("Exterminated"); + this.time = tag.getLong("Time"); + if(tag.hasObject("Generator")) { + this.dimension.fromTags(tag.getObject("Generator")); + if(this.dimension.getType().weather && !this.exterminated) + this.weather = this.dimension.getWeather(); + this.seed = this.dimension.getSeed(); + } + if(this.dimension.getType().weather && !this.exterminated) + this.weather = Weather.getByName(tag.getString("Weather")); + if(this.weather == null) { + this.weather = this.dimension.getWeather(); +// this.dataModified = true; + } + // ... + } + else { + Log.TICK.info("Startwert für %s: %d" + (Config.seed.isEmpty() ? "" : " von Basiswert '%s'"), this.dimension.getFormattedName(false), this.seed, Config.seed); + } + if(this.exterminated) + this.weather = Weather.CLEAR; this.grng = new Random(this.seed); // GeneratorSettings settings = !debug && !this.exterminated ? dim.getSettings() : null; - if(debug) { - this.liquid = Blocks.air.getState(); - this.biomeGen = new BiomeGenSingle(Biome.NONE); - this.generator = new GeneratorDebug(); - this.replacer = null; - this.populate = false; - this.caveGen = null; - this.bigCaveGen = null; - this.ravineGen = null; - this.base = false; - this.ceil = false; - this.mobs = false; - this.snow = false; - this.strongholdGen = null; - this.villageGen = null; - this.mineshaftGen = null; - this.scatteredGen = null; - this.bridgeGen = null; - this.seaLevel = 0; - this.ores = null; - this.lakes = null; - this.liquids = null; - this.dungeons = null; - } - else if(this.exterminated) { + if(this.exterminated) { this.setExterminatedGen(); } // else if(settings != null) { @@ -440,36 +413,34 @@ public final class WorldServer extends AWorldServer { this.calculateInitialSkylight(); this.calculateInitialWeather(); this.updatePhysics(); - if(!debug) { - TagObject tag = null; + tag = null; + try { + File dat = new File(this.chunkDir, "loaders.cdt"); + if(dat.exists() && dat.isFile()) + tag = TagObject.readGZip(dat); + } + catch(Exception e) { + Log.IO.error(e, "Konnte Ladeliste nicht laden"); + } + if(tag != null && tag.hasList("Loaders")) { + List list = tag.getList("Loaders"); + for(int z = 0; z < list.size(); z++) { + TagObject pos = list.get(z); + this.addLoader(new BlockPos(pos.getInt("X"), pos.getInt("Y"), pos.getInt("Z"))); + } + this.loadersModified = false; + } + if(this.villageGen != null) { + tag = null; try { - File dat = new File(this.chunkDir, "loaders.cdt"); + File dat = new File(this.chunkDir, "villages.cdt"); if(dat.exists() && dat.isFile()) tag = TagObject.readGZip(dat); } catch(Exception e) { - Log.IO.error(e, "Konnte Ladeliste nicht laden"); - } - if(tag != null && tag.hasList("Loaders")) { - List list = tag.getList("Loaders"); - for(int z = 0; z < list.size(); z++) { - TagObject pos = list.get(z); - this.addLoader(new BlockPos(pos.getInt("X"), pos.getInt("Y"), pos.getInt("Z"))); - } - this.loadersModified = false; - } - if(this.villageGen != null) { - tag = null; - try { - File dat = new File(this.chunkDir, "villages.cdt"); - if(dat.exists() && dat.isFile()) - tag = TagObject.readGZip(dat); - } - catch(Exception e) { - Log.IO.error(e, "Konnte Dorfliste nicht laden"); - } - this.villageStorage = new VillageCollection(tag); + Log.IO.error(e, "Konnte Dorfliste nicht laden"); } + this.villageStorage = new VillageCollection(tag); } } @@ -486,23 +457,21 @@ public final class WorldServer extends AWorldServer { this.updateWeather(false); this.biomeGen.cleanupCache(); // this.profiler.start("mobSpawner"); - if(this.mobs && Config.mobs && Config.tickSpawn && !this.debug) { + if(this.mobs && Config.mobs && Config.tickSpawn) { Spawner.spawn(this); } // this.profiler.next("chunkSource"); - if(!this.debug) { - for(int i = 0; i < 100; ++i) { - if(!this.dropped.isEmpty()) { - Long v = (Long)this.dropped.iterator().next(); - ChunkServer chunk = this.chunks.getValueByKey(v.longValue()); - if(chunk != null) { - chunk.onChunkUnload(); - this.saveChunkData(chunk); - this.chunks.remove(v.longValue()); - this.loaded.remove(chunk); - } - this.dropped.remove(v); + for(int i = 0; i < 100; ++i) { + if(!this.dropped.isEmpty()) { + Long v = (Long)this.dropped.iterator().next(); + ChunkServer chunk = this.chunks.getValueByKey(v.longValue()); + if(chunk != null) { + chunk.onChunkUnload(); + this.saveChunkData(chunk); + this.chunks.remove(v.longValue()); + this.loaded.remove(chunk); } + this.dropped.remove(v); } } int light = this.calculateSkylightSubtracted(true); @@ -611,113 +580,105 @@ public final class WorldServer extends AWorldServer { } public void setItemData(String dataID, WorldSavedData worldSavedDataIn) { - if(!this.debug) - this.setData(dataID, worldSavedDataIn); + this.setData(dataID, worldSavedDataIn); } public WorldSavedData loadItemData(String dataID) { - return this.debug ? null : this.loadData(dataID); + return this.loadData(dataID); } protected void updateBlocks() { this.setActivePlayerChunksAndCheckLight(Config.distance); - if(this.debug) { - for(ChunkPos chunkcoordintpair1 : this.active) { - this.getChunk(chunkcoordintpair1.x, chunkcoordintpair1.z).update(false); - } - } - else { - int i = 0; - int j = 0; + int i = 0; + int j = 0; - for(ChunkPos chunkcoordintpair : this.active) { - int k = chunkcoordintpair.x * 16; - int l = chunkcoordintpair.z * 16; + for(ChunkPos chunkcoordintpair : this.active) { + int k = chunkcoordintpair.x * 16; + int l = chunkcoordintpair.z * 16; // this.profiler.start("getChunk"); - ChunkServer chunk = this.getChunk(chunkcoordintpair.x, chunkcoordintpair.z); + ChunkServer chunk = this.getChunk(chunkcoordintpair.x, chunkcoordintpair.z); // this.profiler.next("moodSound"); // this.playMoodSound(k, l, chunk); // this.profiler.next("checkLight"); - chunk.enqueueRelight(); + chunk.enqueueRelight(); // this.profiler.next("tickChunk"); - chunk.update(false); + chunk.update(false); // this.profiler.next("thunder"); - int l2 = Config.boltChance; + int l2 = Config.boltChance; - if(l2 > 0 && this.rand.zrange(l2) == 0 && this.isThundering()) { - this.updateLCG = this.updateLCG * 3 + 1013904223; - int i1 = this.updateLCG >> 2; - BlockPos blockpos = this.adjustPosToNearbyEntity(new BlockPos(k + (i1 & 15), 0, l + (i1 >> 8 & 15))); + if(l2 > 0 && this.rand.zrange(l2) == 0 && this.isThundering()) { + this.updateLCG = this.updateLCG * 3 + 1013904223; + int i1 = this.updateLCG >> 2; + BlockPos blockpos = this.adjustPosToNearbyEntity(new BlockPos(k + (i1 & 15), 0, l + (i1 >> 8 & 15))); - if(this.canStrikeAt(blockpos)) { - this.strikeLightning((double)blockpos.getX(), (double)blockpos.getY(), (double)blockpos.getZ(), 0x737380, 120, true, null); - } + if(this.canStrikeAt(blockpos)) { + this.strikeLightning((double)blockpos.getX(), (double)blockpos.getY(), (double)blockpos.getZ(), 0x737380, 120, true, null); } + } // this.profiler.next("iceandsnow"); - l2 = Config.weatherTick; + l2 = Config.weatherTick; - for(int z = 0; z < l2; z++) { - if(this.rand.zrange(16) == 0) { - this.updateLCG = this.updateLCG * 3 + 1013904223; - int k2 = this.updateLCG >> 2; - BlockPos blockpos2 = this.getPrecipitationHeight(new BlockPos(k + (k2 & 15), 0, l + (k2 >> 8 & 15))); - BlockPos blockpos1 = blockpos2.down(); + for(int z = 0; z < l2; z++) { + if(this.rand.zrange(16) == 0) { + this.updateLCG = this.updateLCG * 3 + 1013904223; + int k2 = this.updateLCG >> 2; + BlockPos blockpos2 = this.getPrecipitationHeight(new BlockPos(k + (k2 & 15), 0, l + (k2 >> 8 & 15))); + BlockPos blockpos1 = blockpos2.down(); - if(this.canBlockFreeze(blockpos1, true)) { - this.setState(blockpos1, Blocks.ice.getState()); - } + if(this.canBlockFreeze(blockpos1, true)) { + this.setState(blockpos1, Blocks.ice.getState()); + } - if(this.snow && this.isRaining() && this.canSnowAt(blockpos2, true, Config.snowStack)) { - State layer = Config.snowStack ? this.getState(blockpos2) : null; - this.setState(blockpos2, Config.snowStack && layer.getBlock() == Blocks.snow_layer - ? (Blocks.snow_layer.getState().withProperty(BlockSnow.LAYERS, - Math.min(layer.getValue(BlockSnow.LAYERS) + 1, 2))) : Blocks.snow_layer.getState()); - } + if(this.snow && this.isRaining() && this.canSnowAt(blockpos2, true, Config.snowStack)) { + State layer = Config.snowStack ? this.getState(blockpos2) : null; + this.setState(blockpos2, Config.snowStack && layer.getBlock() == Blocks.snow_layer + ? (Blocks.snow_layer.getState().withProperty(BlockSnow.LAYERS, + Math.min(layer.getValue(BlockSnow.LAYERS) + 1, 2))) : Blocks.snow_layer.getState()); + } - if(this.isRaining()) { // && this.getBiomeGenForCoords(blockpos1).canRain()) { - this.getState(blockpos1).getBlock().fillWithRain(this, blockpos1); - } + if(this.isRaining()) { // && this.getBiomeGenForCoords(blockpos1).canRain()) { + this.getState(blockpos1).getBlock().fillWithRain(this, blockpos1); + } - if(Config.igniteChance > 0 && Config.fire && !this.isRaining() && - this.rand.chance(this.hasDownfall() ? Math.max(1, Config.igniteChance / 3) : Config.igniteChance) - && this.canPlaceFireAt(blockpos2)) { - this.setState(blockpos2, Blocks.fire.getState()); - } + if(Config.igniteChance > 0 && Config.fire && !this.isRaining() && + this.rand.chance(this.hasDownfall() ? Math.max(1, Config.igniteChance / 3) : Config.igniteChance) + && this.canPlaceFireAt(blockpos2)) { + this.setState(blockpos2, Blocks.fire.getState()); } } + } // this.profiler.next("tickBlocks"); - l2 = Config.randomTick; + l2 = Config.randomTick; - if(l2 > 0) { - this.toTick.addAll(chunk.getStorage()); - for(BlockArray extendedblockstorage : this.toTick) { - if(extendedblockstorage != null && extendedblockstorage.isTicked()) { - for(int j1 = 0; j1 < l2; ++j1) { - this.updateLCG = this.updateLCG * 3 + 1013904223; - int k1 = this.updateLCG >> 2; - int l1 = k1 & 15; - int i2 = k1 >> 8 & 15; - int j2 = k1 >> 16 & 15; - ++j; - State iblockstate = extendedblockstorage.get(l1, j2, i2); - Block block = iblockstate.getBlock(); + if(l2 > 0) { + this.toTick.addAll(chunk.getStorage()); + for(BlockArray extendedblockstorage : this.toTick) { + if(extendedblockstorage != null && extendedblockstorage.isTicked()) { + for(int j1 = 0; j1 < l2; ++j1) { + this.updateLCG = this.updateLCG * 3 + 1013904223; + int k1 = this.updateLCG >> 2; + int l1 = k1 & 15; + int i2 = k1 >> 8 & 15; + int j2 = k1 >> 16 & 15; + ++j; + State iblockstate = extendedblockstorage.get(l1, j2, i2); + Block block = iblockstate.getBlock(); - if(block.getTickRandomly()) { - ++i; - block.randomTick(this, new BlockPos(l1 + k, j2 + extendedblockstorage.getY(), i2 + l), iblockstate, - this.rand); - } + if(block.getTickRandomly()) { + ++i; + block.randomTick(this, new BlockPos(l1 + k, j2 + extendedblockstorage.getY(), i2 + l), iblockstate, + this.rand); } } } - this.toTick.clear(); } + this.toTick.clear(); + } // this.profiler.end(); - } } } @@ -813,60 +774,55 @@ public final class WorldServer extends AWorldServer { } public boolean tickUpdates(boolean p_72955_1_) { - if(this.debug) { - return false; + int i = this.ticksNext.size(); + + if(i != this.ticks.size()) { + throw new IllegalStateException("TickNextTick list out of synch"); } else { - int i = this.ticksNext.size(); - - if(i != this.ticks.size()) { - throw new IllegalStateException("TickNextTick list out of synch"); + if(i > 1000) { + i = 1000; } - else { - if(i > 1000) { - i = 1000; - } // this.profiler.start("cleaning"); - for(int j = 0; j < i; ++j) { - NextTickListEntry nextticklistentry = (NextTickListEntry)this.ticksNext.first(); + for(int j = 0; j < i; ++j) { + NextTickListEntry nextticklistentry = (NextTickListEntry)this.ticksNext.first(); - if(!p_72955_1_ && nextticklistentry.scheduledTime > this.time) { - break; - } - - this.ticksNext.remove(nextticklistentry); - this.ticks.remove(nextticklistentry); - this.ticksNow.add(nextticklistentry); + if(!p_72955_1_ && nextticklistentry.scheduledTime > this.time) { + break; } + this.ticksNext.remove(nextticklistentry); + this.ticks.remove(nextticklistentry); + this.ticksNow.add(nextticklistentry); + } + // this.profiler.end(); // this.profiler.start("ticking"); - Iterator iterator = this.ticksNow.iterator(); + Iterator iterator = this.ticksNow.iterator(); - while(iterator.hasNext()) { - NextTickListEntry nextticklistentry1 = (NextTickListEntry)iterator.next(); - iterator.remove(); - int k = 0; + while(iterator.hasNext()) { + NextTickListEntry nextticklistentry1 = (NextTickListEntry)iterator.next(); + iterator.remove(); + int k = 0; - if(this.isAreaLoaded(nextticklistentry1.position.add(-k, -k, -k), nextticklistentry1.position.add(k, k, k))) { - State iblockstate = this.getState(nextticklistentry1.position); + if(this.isAreaLoaded(nextticklistentry1.position.add(-k, -k, -k), nextticklistentry1.position.add(k, k, k))) { + State iblockstate = this.getState(nextticklistentry1.position); - if(iblockstate.getBlock() != Blocks.air - && Block.isEqualTo(iblockstate.getBlock(), nextticklistentry1.getBlock())) { - iblockstate.getBlock().updateTick(this, nextticklistentry1.position, iblockstate, this.rand); - } - } - else { - this.scheduleUpdate(nextticklistentry1.position, nextticklistentry1.getBlock(), 0); + if(iblockstate.getBlock() != Blocks.air + && Block.isEqualTo(iblockstate.getBlock(), nextticklistentry1.getBlock())) { + iblockstate.getBlock().updateTick(this, nextticklistentry1.position, iblockstate, this.rand); } } + else { + this.scheduleUpdate(nextticklistentry1.position, nextticklistentry1.getBlock(), 0); + } + } // this.profiler.end(); - this.ticksNow.clear(); - return !this.ticksNext.isEmpty(); - } + this.ticksNow.clear(); + return !this.ticksNext.isEmpty(); } } @@ -1008,84 +964,82 @@ public final class WorldServer extends AWorldServer { } public void saveAllChunks() { - if(/* (force || !this.disableSaving) && */ !this.debug) { // if(this.primary) { // // } - if(this.loadersModified) { - this.loadersModified = false; - TagObject loaders = new TagObject(); - List list = Lists.newArrayList(); - for(BlockPos pos : this.loaderList) { - TagObject loader = new TagObject(); - loader.setInt("X", pos.getX()); - loader.setInt("Y", pos.getY()); - loader.setInt("Z", pos.getZ()); - list.add(loader); + if(this.loadersModified) { + this.loadersModified = false; + TagObject loaders = new TagObject(); + List list = Lists.newArrayList(); + for(BlockPos pos : this.loaderList) { + TagObject loader = new TagObject(); + loader.setInt("X", pos.getX()); + loader.setInt("Y", pos.getY()); + loader.setInt("Z", pos.getZ()); + list.add(loader); + } + loaders.setList("Loaders", list); + File file = new File(this.chunkDir, "loaders.cdt"); + if(list.isEmpty()) { + file.delete(); + } + else { + try { + TagObject.writeGZip(loaders, file); } - loaders.setList("Loaders", list); - File file = new File(this.chunkDir, "loaders.cdt"); - if(list.isEmpty()) { - file.delete(); - } - else { - try { - TagObject.writeGZip(loaders, file); - } - catch(Exception e) { - Log.IO.error(e, "Konnte Ladeliste nicht speichern"); - } + catch(Exception e) { + Log.IO.error(e, "Konnte Ladeliste nicht speichern"); } } + } // if(this.warpsModified) { // this.warpsModified = false; // } // if(this.dataModified) { // this.dataModified = false; - TagObject data = new TagObject(); + TagObject data = new TagObject(); // data.setLong("Seed", this.seed); - data.setObject("Generator", this.dimension.toTags(true)); - data.setLong("Time", this.time); - data.setBool("Exterminated", this.exterminated); - data.setString("Weather", this.weather.getName()); - // ... - File file = new File(this.chunkDir, "data.cdt"); + data.setObject("Generator", this.dimension.toTags(true)); + data.setLong("Time", this.time); + data.setBool("Exterminated", this.exterminated); + data.setString("Weather", this.weather.getName()); + // ... + File file = new File(this.chunkDir, "data.cdt"); + try { + TagObject.writeGZip(data, file); + } + catch(Exception e) { + Log.IO.error(e, "Konnte Weltdaten nicht speichern"); + } +// } + for(int i = 0; i < this.dataList.size(); ++i) { + WorldSavedData wdata = this.dataList.get(i); + if(wdata.dirty) { + this.saveData(wdata); + wdata.dirty = false; + } + } + if(this.villageStorage != null && this.villageStorage.isDirty()) { + TagObject tag = this.villageStorage.toTags(); + File dat = new File(this.chunkDir, "villages.cdt"); try { - TagObject.writeGZip(data, file); + TagObject.writeGZip(tag, dat); } catch(Exception e) { - Log.IO.error(e, "Konnte Weltdaten nicht speichern"); + Log.IO.error(e, "Konnte Dorfliste nicht speichern"); } -// } - for(int i = 0; i < this.dataList.size(); ++i) { - WorldSavedData wdata = this.dataList.get(i); - if(wdata.dirty) { - this.saveData(wdata); - wdata.dirty = false; - } + } + List list = Lists.newArrayList(this.loaded); + for(int n = 0; n < list.size(); ++n) { + ChunkServer chunk = list.get(n); + if(chunk.isDirty(this.time)) { + this.saveChunkData(chunk); + chunk.setModified(false); } - if(this.villageStorage != null && this.villageStorage.isDirty()) { - TagObject tag = this.villageStorage.toTags(); - File dat = new File(this.chunkDir, "villages.cdt"); - try { - TagObject.writeGZip(tag, dat); - } - catch(Exception e) { - Log.IO.error(e, "Konnte Dorfliste nicht speichern"); - } - } - List list = Lists.newArrayList(this.loaded); - for(int n = 0; n < list.size(); ++n) { - ChunkServer chunk = list.get(n); - if(chunk.isDirty(this.time)) { - this.saveChunkData(chunk); - chunk.setModified(false); - } - } - for(ChunkServer chunk : Lists.newArrayList(this.loaded)) { - if(chunk != null && !this.hasPlayerInstance(chunk.xPos, chunk.zPos)) { - this.dropChunk(chunk.xPos, chunk.zPos); - } + } + for(ChunkServer chunk : Lists.newArrayList(this.loaded)) { + if(chunk != null && !this.hasPlayerInstance(chunk.xPos, chunk.zPos)) { + this.dropChunk(chunk.xPos, chunk.zPos); } } } @@ -1368,8 +1322,7 @@ public final class WorldServer extends AWorldServer { ChunkServer chunk = this.chunks.getValueByKey(id); if(chunk == null) { - if(!this.debug) - chunk = this.loadChunkFromFile(x, z); + chunk = this.loadChunkFromFile(x, z); if(chunk == null) { chunk = this.generate(x, z); @@ -1645,8 +1598,6 @@ public final class WorldServer extends AWorldServer { } public boolean exterminate() { - if(this.debug) - return true; if(this.exterminated) return false; this.setWeather(Weather.CLEAR); diff --git a/server/src/main/java/server/worldgen/GeneratorDebug.java b/server/src/main/java/server/worldgen/GeneratorDebug.java deleted file mode 100755 index 1158b5c..0000000 --- a/server/src/main/java/server/worldgen/GeneratorDebug.java +++ /dev/null @@ -1,27 +0,0 @@ -package server.worldgen; - -import common.world.DebugStates; -import common.world.State; -import server.world.WorldServer; - -public class GeneratorDebug implements ChunkGenerator -{ - public int getMaximumHeight() { - return 72; - } - - public void generateChunk(WorldServer world, int x, int z, ChunkPrimer primer) - { - for(int bx = 0; bx < 16; ++bx) { - for(int bz = 0; bz < 16; ++bz) { - int sx = x * 16 + bx; - int sz = z * 16 + bz; -// primer.set(bx, 60, bz, Blocks.glass.getDefaultState()); - State state = DebugStates.getState(sx, sz); - if(state != null) { - primer.set(bx, 1, bz, state); - } - } - } - } -}