From 399cf8b6a2b2b4c4ba27e7568a8815e7c1259244 Mon Sep 17 00:00:00 2001 From: LemADEC Date: Fri, 14 Aug 2015 01:51:50 +0200 Subject: [PATCH] Updated debug logs Fixed #54 Replaced debug configuration with a logging section for finer adjustment --- src/main/java/cr0s/warpdrive/EntityJump.java | 138 ++++++++++++------ src/main/java/cr0s/warpdrive/WarpDrive.java | 26 ++-- .../block/TileEntityAbstractChunkLoading.java | 35 ++--- .../cr0s/warpdrive/block/TileEntityLaser.java | 28 +++- .../block/building/TileEntityShipScanner.java | 11 +- .../collection/TileEntityLaserTreeFarm.java | 8 +- .../collection/TileEntityMiningLaser.java | 4 +- .../block/detection/TileEntityCamera.java | 5 +- .../detection/TileEntityCloakingCore.java | 24 ++- .../block/detection/TileEntityMonitor.java | 5 +- .../energy/TileEntityEnanReactorCore.java | 40 ++--- .../movement/TileEntityShipController.java | 24 ++- .../block/movement/TileEntityShipCore.java | 44 +++--- .../block/movement/TileEntityTransporter.java | 66 +++++---- .../block/weapon/BlockLaserCamera.java | 5 +- .../cr0s/warpdrive/conf/WarpDriveConfig.java | 70 ++++++--- .../cr0s/warpdrive/data/CamerasRegistry.java | 51 +++++-- .../cr0s/warpdrive/data/CloakManager.java | 5 +- .../java/cr0s/warpdrive/data/CloakedArea.java | 7 +- .../java/cr0s/warpdrive/data/JumpBlock.java | 4 +- .../warpdrive/data/ShipCoresRegistry.java | 10 +- .../cr0s/warpdrive/item/ItemComponent.java | 3 +- .../java/cr0s/warpdrive/item/ItemHelmet.java | 13 +- .../warpdrive/network/BeamEffectMessage.java | 110 -------------- .../warpdrive/network/MessageBeamEffect.java | 4 +- .../cr0s/warpdrive/network/MessageCloak.java | 12 +- .../warpdrive/network/MessageFrequency.java | 4 +- .../warpdrive/network/MessageTargeting.java | 4 +- .../cr0s/warpdrive/network/PacketHandler.java | 13 +- .../cr0s/warpdrive/render/CameraOverlay.java | 2 +- .../warpdrive/render/ClientCameraUtils.java | 9 +- .../cr0s/warpdrive/render/EntityCamera.java | 4 +- .../cr0s/warpdrive/world/EntitySphereGen.java | 2 +- .../cr0s/warpdrive/world/EntityStarCore.java | 4 +- 34 files changed, 437 insertions(+), 357 deletions(-) delete mode 100644 src/main/java/cr0s/warpdrive/network/BeamEffectMessage.java diff --git a/src/main/java/cr0s/warpdrive/EntityJump.java b/src/main/java/cr0s/warpdrive/EntityJump.java index d2365fc9..0393eece 100644 --- a/src/main/java/cr0s/warpdrive/EntityJump.java +++ b/src/main/java/cr0s/warpdrive/EntityJump.java @@ -93,8 +93,9 @@ public class EntityJump extends Entity { public EntityJump(World world) { super(world); targetWorld = worldObj; - WarpDrive.debugPrint("" + this + " Entity created (empty) in dimension " + worldObj.getProviderName() + " - " + worldObj.getWorldInfo().getWorldName() - + " " + (FMLCommonHandler.instance().getEffectiveSide().isClient() ? "Client" : "Server")); + if (WarpDriveConfig.LOGGING_JUMP) { + WarpDrive.logger.info(this + " Entity created (empty) in dimension " + worldObj.getProviderName() + " - " + worldObj.getWorldInfo().getWorldName()); + } } public EntityJump(World world, int x, int y, int z, int _dx, int _dz, TileEntityShipCore _reactor, boolean _isHyperspaceJump, int _distance, int _direction, @@ -124,7 +125,9 @@ public class EntityJump extends Entity { // set when preparing jump targetWorld = null; - WarpDrive.debugPrint("" + this + " Entity created"); + if (WarpDriveConfig.LOGGING_JUMP) { + WarpDrive.logger.info(this + " Entity created"); + } } public void killEntity(String reason) { @@ -134,10 +137,12 @@ public class EntityJump extends Entity { on = false; - if (reason == null || reason.isEmpty()) { - WarpDrive.debugPrint("" + this + " Killing jump entity..."); - } else { - WarpDrive.debugPrint("" + this + " Killing jump entity... (" + reason + ")"); + if (WarpDriveConfig.LOGGING_JUMP) { + if (reason == null || reason.isEmpty()) { + WarpDrive.logger.info(this + " Killing jump entity..."); + } else { + WarpDrive.logger.info(this + " Killing jump entity... (" + reason + ")"); + } } unforceChunks(); @@ -156,7 +161,9 @@ public class EntityJump extends Entity { } if (!on) { - WarpDrive.debugPrint(this + " Removing from onUpdate..."); + if (WarpDriveConfig.LOGGING_JUMP) { + WarpDrive.logger.info(this + " Removing from onUpdate..."); + } worldObj.removeEntity(this); return; } @@ -170,7 +177,9 @@ public class EntityJump extends Entity { ticks++; if (state == STATE_IDLE) { - WarpDrive.debugPrint(this + " Preparing to jump..."); + if (WarpDriveConfig.LOGGING_JUMP) { + WarpDrive.logger.info(this + " Preparing to jump..."); + } prepareToJump(); if (on) { state = STATE_JUMPING; @@ -202,7 +211,9 @@ public class EntityJump extends Entity { private boolean forceChunks(StringBuilder reason) { LocalProfiler.start("EntityJump.forceChunks"); - WarpDrive.debugPrint("" + this + " Forcing chunks in " + worldObj.provider.getDimensionName() + " and " + targetWorld.provider.getDimensionName()); + if (WarpDriveConfig.LOGGING_JUMP) { + WarpDrive.logger.info(this + " Forcing chunks in " + worldObj.provider.getDimensionName() + " and " + targetWorld.provider.getDimensionName()); + } sourceWorldTicket = ForgeChunkManager.requestTicket(WarpDrive.instance, worldObj, Type.NORMAL); // Type.ENTITY); if (sourceWorldTicket == null) { reason.append("Chunkloading rejected in S:" + worldObj.getWorldInfo().getWorldName() + ". Aborting."); @@ -251,7 +262,9 @@ public class EntityJump extends Entity { private void unforceChunks() { LocalProfiler.start("EntityJump.unforceChunks"); - WarpDrive.debugPrint("" + this + " Unforcing chunks"); + if (WarpDriveConfig.LOGGING_JUMP) { + WarpDrive.logger.info(this + " Unforcing chunks"); + } int x1, x2, z1, z2; if (sourceWorldTicket != null) { @@ -453,8 +466,8 @@ public class EntityJump extends Entity { } } - if (betweenWorlds) { - WarpDrive.debugPrint("" + this + " Worlds: " + worldObj.provider.getDimensionName() + " -> " + targetWorld.provider.getDimensionName()); + if (betweenWorlds && WarpDriveConfig.LOGGING_JUMP) { + WarpDrive.logger.info(this + " Worlds: " + worldObj.provider.getDimensionName() + " -> " + targetWorld.provider.getDimensionName()); } // Validate positions aren't overlapping @@ -481,7 +494,9 @@ public class EntityJump extends Entity { } // lockWorlds(); saveEntities(); - WarpDrive.debugPrint("" + this + " Saved " + entitiesOnShip.size() + " entities from ship"); + if (WarpDriveConfig.LOGGING_JUMP) { + WarpDrive.logger.info(this + " Saved " + entitiesOnShip.size() + " entities from ship"); + } if (isHyperspaceJump && isInSpace) { messageToAllPlayersOnShip("Entering HYPERSPACE..."); @@ -507,28 +522,36 @@ public class EntityJump extends Entity { this.currentIndexInShip = 0; msCounter = System.currentTimeMillis(); LocalProfiler.stop(); - WarpDrive.debugPrint("Removing TE duplicates: tileEntities in target world before jump: " + targetWorld.loadedTileEntityList.size()); + if (WarpDriveConfig.LOGGING_JUMP) { + WarpDrive.logger.info("Removing TE duplicates: tileEntities in target world before jump: " + targetWorld.loadedTileEntityList.size()); + } } /** * Finish jump: move entities, unlock worlds and delete self */ private void finishJump() { - WarpDrive.debugPrint("" + this + " Jump done in " + ((System.currentTimeMillis() - msCounter) / 1000F) + " seconds and " + ticks + " ticks"); // FIXME TileEntity duplication workaround - WarpDrive.debugPrint("Removing TE duplicates: tileEntities in target world after jump, before cleanup: " + targetWorld.loadedTileEntityList.size()); + if (WarpDriveConfig.LOGGING_JUMP) { + WarpDrive.logger.info(this + " Jump done in " + ((System.currentTimeMillis() - msCounter) / 1000F) + " seconds and " + ticks + " ticks"); + WarpDrive.logger.info("Removing TE duplicates: tileEntities in target world after jump, before cleanup: " + targetWorld.loadedTileEntityList.size()); + } LocalProfiler.start("EntityJump.removeDuplicates()"); try { targetWorld.loadedTileEntityList = this.removeDuplicates(targetWorld.loadedTileEntityList); - } catch (Exception e) { - WarpDrive.debugPrint("TE Duplicates removing exception: " + e.getMessage()); + } catch (Exception exception) { + if (WarpDriveConfig.LOGGING_JUMP) { + WarpDrive.logger.info("TE Duplicates removing exception: " + exception.getMessage()); + } } FixASTurbines(); doCollisionDamage(true); LocalProfiler.stop(); - WarpDrive.debugPrint("Removing TE duplicates: tileEntities in target world after jump, after cleanup: " + targetWorld.loadedTileEntityList.size()); + if (WarpDriveConfig.LOGGING_JUMP) { + WarpDrive.logger.info("Removing TE duplicates: tileEntities in target world after jump, after cleanup: " + targetWorld.loadedTileEntityList.size()); + } killEntity("Jump done"); } @@ -539,8 +562,9 @@ public class EntityJump extends Entity { private void removeShip() { LocalProfiler.start("EntityJump.removeShip"); int blocksToMove = Math.min(WarpDriveConfig.G_BLOCKS_PER_TICK, ship.length - currentIndexInShip); - WarpDrive.debugPrint("" + this + " Removing ship blocks " + currentIndexInShip + " to " + (currentIndexInShip + blocksToMove - 1) + " / " - + (ship.length - 1)); + if (WarpDriveConfig.LOGGING_JUMP) { + WarpDrive.logger.info(this + " Removing ship blocks " + currentIndexInShip + " to " + (currentIndexInShip + blocksToMove - 1) + " / " + (ship.length - 1)); + } TileEntity te; Class teClass; Class teSuperclass; @@ -550,7 +574,9 @@ public class EntityJump extends Entity { } JumpBlock jb = ship[ship.length - currentIndexInShip - 1]; if (jb == null) { - WarpDrive.debugPrint("" + this + " Removing ship part: unexpected null found at ship[" + currentIndexInShip + "]"); + if (WarpDriveConfig.LOGGING_JUMP) { + WarpDrive.logger.info(this + " Removing ship part: unexpected null found at ship[" + currentIndexInShip + "]"); + } currentIndexInShip++; continue; } @@ -673,7 +699,9 @@ public class EntityJump extends Entity { return; } - WarpDrive.debugPrint("" + this + " Ship saved as " + ship.length + " blocks"); + if (WarpDriveConfig.LOGGING_JUMP) { + WarpDrive.logger.info(this + " Ship saved as " + ship.length + " blocks"); + } LocalProfiler.stop(); } @@ -683,8 +711,9 @@ public class EntityJump extends Entity { private void moveShip() { LocalProfiler.start("EntityJump.moveShip"); int blocksToMove = Math.min(WarpDriveConfig.G_BLOCKS_PER_TICK, ship.length - currentIndexInShip); - WarpDrive.debugPrint("" + this + " Moving ship blocks " + currentIndexInShip + " to " + (currentIndexInShip + blocksToMove - 1) + " / " - + (ship.length - 1)); + if (WarpDriveConfig.LOGGING_JUMP) { + WarpDrive.logger.info(this + " Moving ship blocks " + currentIndexInShip + " to " + (currentIndexInShip + blocksToMove - 1) + " / " + (ship.length - 1)); + } for (int index = 0; index < blocksToMove; index++) { if (currentIndexInShip >= ship.length) { @@ -709,7 +738,9 @@ public class EntityJump extends Entity { * @return possible jump distance or -1 */ private int getPossibleJumpDistance() { - WarpDrive.debugPrint("" + this + " Calculating possible jump distance..."); + if (WarpDriveConfig.LOGGING_JUMP) { + WarpDrive.logger.info(this + " Calculating possible jump distance..."); + } int testDistance = this.distance; int blowPoints = 0; collisionDetected = false; @@ -729,8 +760,8 @@ public class EntityJump extends Entity { testDistance--; } - if (distance != testDistance) { - WarpDrive.debugPrint("" + this + " Jump distance adjusted to " + testDistance + " after " + blowPoints + " collisions"); + if (distance != testDistance && WarpDriveConfig.LOGGING_JUMP) { + WarpDrive.logger.info(this + " Jump distance adjusted to " + testDistance + " after " + blowPoints + " collisions"); } // Register explosion(s) at collision point @@ -748,9 +779,9 @@ public class EntityJump extends Entity { collisionStrength = (4.0F + blowPoints - WarpDriveConfig.WC_COLLISION_TOLERANCE_BLOCKS) * massCorrection; collisionAtSource = result.atSource; collisionAtTarget = result.atTarget; - WarpDrive.debugPrint("" + this + " Reporting " + collisionAtTarget.size() + " collisions coordinates " + blowPoints - + " blowPoints with massCorrection of " + String.format("%.2f", massCorrection) + " => strength " - + String.format("%.2f", collisionStrength)); + WarpDrive.logger.info(this + " Reporting " + collisionAtTarget.size() + " collisions coordinates " + blowPoints + + " blowPoints with massCorrection of " + String.format("%.2f", massCorrection) + " => strength " + + String.format("%.2f", collisionStrength)); } else { WarpDrive.logger.error("WarpDrive error: unable to compute collision points, ignoring..."); } @@ -761,7 +792,9 @@ public class EntityJump extends Entity { private void doCollisionDamage(boolean atTarget) { if (!collisionDetected) { - WarpDrive.debugPrint("" + this + " doCollisionDamage No collision detected..."); + if (WarpDriveConfig.LOGGING_JUMP) { + WarpDrive.logger.info(this + " doCollisionDamage No collision detected..."); + } return; } ArrayList collisionPoints = atTarget ? collisionAtTarget : collisionAtSource; @@ -795,15 +828,21 @@ public class EntityJump extends Entity { // randomize if too many collision points int nbExplosions = Math.min(5, collisionPoints.size()); - WarpDrive.debugPrint("doCollisionDamage nbExplosions " + nbExplosions + "/" + collisionPoints.size()); + if (WarpDriveConfig.LOGGING_JUMP) { + WarpDrive.logger.info("doCollisionDamage nbExplosions " + nbExplosions + "/" + collisionPoints.size()); + } for (int i = 0; i < nbExplosions; i++) { // get location Vector3 current; if (nbExplosions < collisionPoints.size()) { - WarpDrive.debugPrint("doCollisionDamage random #" + i); + if (WarpDriveConfig.LOGGING_JUMP) { + WarpDrive.logger.info("doCollisionDamage random #" + i); + } current = collisionPoints.get(worldObj.rand.nextInt(collisionPoints.size())); } else { - WarpDrive.debugPrint("doCollisionDamage get " + i); + if (WarpDriveConfig.LOGGING_JUMP) { + WarpDrive.logger.info("doCollisionDamage get " + i); + } current = collisionPoints.get(i); } @@ -811,7 +850,7 @@ public class EntityJump extends Entity { float strength = Math.max(4.0F, collisionStrength / nbExplosions - 2.0F + 2.0F * worldObj.rand.nextFloat()); (atTarget ? targetWorld : worldObj).newExplosion((Entity) null, current.x, current.y, current.z, strength, atTarget, atTarget); - WarpDrive.debugPrint("doCollisionDamage explosion at " + current.x + ", " + current.y + ", " + current.z + " with strength " + strength); + WarpDrive.logger.info("Ship collision caused explosion at " + current.x + ", " + current.y + ", " + current.z + " with strength " + strength); } } @@ -831,8 +870,8 @@ public class EntityJump extends Entity { shipVolume++; - if (WarpDriveConfig.G_DEBUGMODE) { - WarpDrive.debugPrint("Block(" + x + ", " + y + ", " + z + ") is " + block.getUnlocalizedName() + "@" + worldObj.getBlockMetadata(x, y, z)); + if (WarpDriveConfig.LOGGING_JUMP) { + WarpDrive.logger.info("Block(" + x + ", " + y + ", " + z + ") is " + block.getUnlocalizedName() + "@" + worldObj.getBlockMetadata(x, y, z)); } if (block.isAssociatedBlock(Blocks.bedrock)) {// Blacklist @@ -904,7 +943,9 @@ public class EntityJump extends Entity { } private boolean moveEntities(boolean restorePositions) { - WarpDrive.debugPrint("" + this + " Moving entities"); + if (WarpDriveConfig.LOGGING_JUMP) { + WarpDrive.logger.info(this + " Moving entities"); + } LocalProfiler.start("EntityJump.moveEntities"); if (entitiesOnShip != null) { @@ -1030,8 +1071,9 @@ public class EntityJump extends Entity { atTarget.add(new Vector3(tx, ty, tz)); isCollision = isCollision || pisCollision; reason = preason; - WarpDrive.debugPrint("CheckMovementResult " + sx + ", " + sy + ", " + sz + " -> " + tx + ", " + ty + ", " + tz + " " + isCollision + " '" + reason - + "'"); + if (WarpDriveConfig.LOGGING_JUMP) { + WarpDrive.logger.info("CheckMovementResult " + sx + ", " + sy + ", " + sz + " -> " + tx + ", " + ty + ", " + tz + " " + isCollision + " '" + reason + "'"); + } } }; @@ -1104,7 +1146,9 @@ public class EntityJump extends Entity { @Override public int compare(TileEntity o1, TileEntity o2) { if (o1.xCoord == o2.xCoord && o1.yCoord == o2.yCoord && o1.zCoord == o2.zCoord) { - WarpDrive.debugPrint("Removed duplicated TE: " + o1 + ", " + o2); + if (WarpDriveConfig.LOGGING_JUMP) { + WarpDrive.logger.info("Removed duplicated TE: " + o1 + ", " + o2); + } return 0; } else { return 1; @@ -1117,19 +1161,19 @@ public class EntityJump extends Entity { @Override protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { - WarpDrive.logger.info("" + this + " readEntityFromNBT()"); + WarpDrive.logger.error("" + this + " readEntityFromNBT()"); } @Override protected void entityInit() { - if (WarpDriveConfig.G_DEBUGMODE) { - WarpDrive.debugPrint("" + this + " entityInit()"); + if (WarpDriveConfig.LOGGING_JUMP) { + WarpDrive.logger.warn("" + this + " entityInit()"); } } @Override protected void writeEntityToNBT(NBTTagCompound var1) { - WarpDrive.debugPrint("" + this + " writeEntityToNBT()"); + WarpDrive.logger.error("" + this + " writeEntityToNBT()"); } private void FixASTurbines() { diff --git a/src/main/java/cr0s/warpdrive/WarpDrive.java b/src/main/java/cr0s/warpdrive/WarpDrive.java index ed8173d7..79c3f070 100644 --- a/src/main/java/cr0s/warpdrive/WarpDrive.java +++ b/src/main/java/cr0s/warpdrive/WarpDrive.java @@ -213,12 +213,6 @@ public class WarpDrive implements LoadingCallback { PacketHandler.init(); } - public static void debugPrint(String out) { - if (WarpDriveConfig.G_DEBUGMODE) { - logger.info(out); - } - } - @EventHandler public void load(FMLInitializationEvent event) { WarpDriveConfig.load(); @@ -750,10 +744,10 @@ public class WarpDrive implements LoadingCallback { te.refreshLoading(); return t; } else { - WarpDrive.debugPrint("Ticket not granted"); + WarpDrive.logger.error("Ticket not granted"); } } else { - WarpDrive.debugPrint("No tickets left!"); + WarpDrive.logger.error("No tickets left!"); } return null; } @@ -776,14 +770,14 @@ public class WarpDrive implements LoadingCallback { int y = data.getInteger("ticketY"); int z = data.getInteger("ticketZ"); if (w != 0 || x != 0 || y != 0 || z != 0) { - WorldServer ws = DimensionManager.getWorld(w); - if (ws != null) { - TileEntity te = ws.getTileEntity(x, y, z); - if (te != null && te instanceof TileEntityAbstractChunkLoading) { - if (((TileEntityAbstractChunkLoading) te).shouldChunkLoad()) { - WarpDrive.debugPrint("[TicketCallback] Regiving Ticket!"); - ((TileEntityAbstractChunkLoading) te).giveTicket(ticket); - ((TileEntityAbstractChunkLoading) te).refreshLoading(true); + WorldServer worldServer = DimensionManager.getWorld(w); + if (worldServer != null) { + TileEntity tileEntity = worldServer.getTileEntity(x, y, z); + if (tileEntity != null && tileEntity instanceof TileEntityAbstractChunkLoading) { + if (((TileEntityAbstractChunkLoading) tileEntity).shouldChunkLoad()) { + WarpDrive.logger.info("ChunkLoadingTicket is loading " + tileEntity); + ((TileEntityAbstractChunkLoading) tileEntity).giveTicket(ticket); + ((TileEntityAbstractChunkLoading) tileEntity).refreshLoading(true); return; } } diff --git a/src/main/java/cr0s/warpdrive/block/TileEntityAbstractChunkLoading.java b/src/main/java/cr0s/warpdrive/block/TileEntityAbstractChunkLoading.java index da326373..82bf909d 100644 --- a/src/main/java/cr0s/warpdrive/block/TileEntityAbstractChunkLoading.java +++ b/src/main/java/cr0s/warpdrive/block/TileEntityAbstractChunkLoading.java @@ -10,6 +10,7 @@ import net.minecraftforge.common.ForgeChunkManager.Ticket; import com.google.common.collect.ImmutableSet; import cr0s.warpdrive.WarpDrive; +import cr0s.warpdrive.conf.WarpDriveConfig; public abstract class TileEntityAbstractChunkLoading extends TileEntityAbstractEnergy { @@ -63,7 +64,7 @@ public abstract class TileEntityAbstractChunkLoading extends TileEntityAbstractE t = ticketList.get(tickNum); } - WarpDrive.debugPrint("Attempting to force chunk" + chunk); + WarpDrive.logger.info("Attempting to force chunk" + chunk); ForgeChunkManager.forceChunk(t, chunk); chunkInTicket++; } @@ -124,16 +125,15 @@ public abstract class TileEntityAbstractChunkLoading extends TileEntityAbstractE int maxX = Math.max(chunkA.chunkXPos, chunkB.chunkXPos); int minZ = Math.min(chunkA.chunkZPos, chunkB.chunkZPos); int maxZ = Math.max(chunkA.chunkZPos, chunkB.chunkZPos); - WarpDrive.debugPrint("From " + minX + "," + minZ + " to " + maxX + "," + maxZ); + WarpDrive.logger.info("ChunkLoading from " + minX + "," + minZ + " to " + maxX + "," + maxZ); //REMOVE ODD SIZES int deltaX = (maxX - minX + 1); int deltaZ = (maxZ - minZ + 1); - WarpDrive.debugPrint("Allocating Block: " + deltaX + "," + deltaZ); maxX = minX + deltaX - 1; maxZ = minZ + deltaZ - 1; - WarpDrive.debugPrint("From " + minX + "," + minZ + " to " + maxX + "," + maxZ); + WarpDrive.logger.info("Allocating " + deltaX + " x " + deltaZ + " blocks from " + minX + "," + minZ + " to " + maxX + "," + maxZ); int maxEnts = (deltaX) * (deltaZ); ArrayList chunkList = new ArrayList(maxEnts); @@ -170,32 +170,33 @@ public abstract class TileEntityAbstractChunkLoading extends TileEntityAbstractE return chunkList; } + @Override - public void writeToNBT(NBTTagCompound t) + public void writeToNBT(NBTTagCompound tag) { - super.writeToNBT(t); + super.writeToNBT(tag); if(minChunk == null) minChunk = worldObj.getChunkFromBlockCoords(xCoord, zCoord).getChunkCoordIntPair(); if(maxChunk == null) maxChunk = worldObj.getChunkFromBlockCoords(xCoord, zCoord).getChunkCoordIntPair(); - t.setInteger("minChunkX", minChunk.chunkXPos); - t.setInteger("minChunkZ", minChunk.chunkZPos); - t.setInteger("maxChunkX", maxChunk.chunkXPos); - t.setInteger("maxChunkZ", maxChunk.chunkZPos); + tag.setInteger("minChunkX", minChunk.chunkXPos); + tag.setInteger("minChunkZ", minChunk.chunkZPos); + tag.setInteger("maxChunkX", maxChunk.chunkXPos); + tag.setInteger("maxChunkZ", maxChunk.chunkZPos); } @Override - public void readFromNBT(NBTTagCompound t) + public void readFromNBT(NBTTagCompound tag) { - super.readFromNBT(t); - if(t.hasKey("minChunkX")) + super.readFromNBT(tag); + if(tag.hasKey("minChunkX")) { - int mx = t.getInteger("minChunkX"); - int mz = t.getInteger("minChunkZ"); + int mx = tag.getInteger("minChunkX"); + int mz = tag.getInteger("minChunkZ"); minChunk = new ChunkCoordIntPair(mx,mz); - mx = t.getInteger("maxChunkX"); - mz = t.getInteger("maxChunkZ"); + mx = tag.getInteger("maxChunkX"); + mz = tag.getInteger("maxChunkZ"); maxChunk = new ChunkCoordIntPair(mx,mz); } } diff --git a/src/main/java/cr0s/warpdrive/block/TileEntityLaser.java b/src/main/java/cr0s/warpdrive/block/TileEntityLaser.java index 802eaee2..231db6d0 100644 --- a/src/main/java/cr0s/warpdrive/block/TileEntityLaser.java +++ b/src/main/java/cr0s/warpdrive/block/TileEntityLaser.java @@ -118,9 +118,13 @@ public class TileEntityLaser extends TileEntityAbstractInterfaced { public void addBeamEnergy(int amount) { if (isEmitting) { energyFromOtherBeams += amount; - WarpDrive.debugPrint(this + " Added energy " + amount); + if (WarpDriveConfig.LOGGING_WEAPON) { + WarpDrive.logger.info(this + " Added energy " + amount); + } } else { - WarpDrive.debugPrint(this + " Ignored energy " + amount); + if (WarpDriveConfig.LOGGING_WEAPON) { + WarpDrive.logger.info(this + " Ignored energy " + amount); + } } } @@ -156,7 +160,9 @@ public class TileEntityLaser extends TileEntityAbstractInterfaced { } Vector3 beamVector = new Vector3(this).translate(0.5D); - WarpDrive.debugPrint(this + " Energy " + energy + " over " + beamLengthBlocks + " blocks, Initial beam " + beamVector); + if (WarpDriveConfig.LOGGING_WEAPON) { + WarpDrive.logger.info(this + " Energy " + energy + " over " + beamLengthBlocks + " blocks, Initial beam " + beamVector); + } float yawz = MathHelper.cos(-yaw * 0.017453292F - (float) Math.PI); float yawx = MathHelper.sin(-yaw * 0.017453292F - (float) Math.PI); float pitchhorizontal = -MathHelper.cos(-pitch * 0.017453292F); @@ -166,7 +172,9 @@ public class TileEntityLaser extends TileEntityAbstractInterfaced { Vector3 lookVector = new Vector3(directionx, pitchvertical, directionz); Vector3.translate(beamVector, lookVector); Vector3 reachPoint = Vector3.translate(beamVector.clone(), Vector3.scale(lookVector.clone(), beamLengthBlocks)); - WarpDrive.debugPrint(this + " Beam " + beamVector + " Look " + lookVector + " Reach " + reachPoint + " TranslatedBeam " + beamVector); + if (WarpDriveConfig.LOGGING_WEAPON) { + WarpDrive.logger.info(this + " Beam " + beamVector + " Look " + lookVector + " Reach " + reachPoint + " TranslatedBeam " + beamVector); + } Vector3 endPoint = reachPoint.clone(); playSoundCorrespondsEnergy(energy); int distanceTravelled = 0; // distance traveled from beam sender to @@ -200,7 +208,9 @@ public class TileEntityLaser extends TileEntityAbstractInterfaced { // FIXME entity ray-tracing MovingObjectPosition entityHit = raytraceEntities(beamVector.clone(), lookVector.clone(), true, beamLengthBlocks); - WarpDrive.debugPrint("Entity hit is " + entityHit); + if (WarpDriveConfig.LOGGING_WEAPON) { + WarpDrive.logger.info("Entity hit is " + entityHit); + } if (entityHit != null && entityHit.entityHit instanceof EntityLivingBase) { EntityLivingBase e = (EntityLivingBase) entityHit.entityHit; @@ -344,7 +354,9 @@ public class TileEntityLaser extends TileEntityAbstractInterfaced { public void setBeamFrequency(int parBeamFrequency) { if (beamFrequency != parBeamFrequency && (parBeamFrequency <= BEAM_FREQUENCY_MAX) && (parBeamFrequency > 0)) { - WarpDrive.debugPrint(this + " Beam frequency set from " + beamFrequency + " to " + parBeamFrequency); + if (WarpDriveConfig.LOGGING_FREQUENCY) { + WarpDrive.logger.info(this + " Beam frequency set from " + beamFrequency + " to " + parBeamFrequency); + } beamFrequency = parBeamFrequency; } updateColor(); @@ -356,7 +368,9 @@ public class TileEntityLaser extends TileEntityAbstractInterfaced { public void setCameraFrequency(int parCameraFrequency) { if (cameraFrequency != parCameraFrequency) { - WarpDrive.debugPrint(this + " Camera frequency set from " + cameraFrequency + " to " + parCameraFrequency); + if (WarpDriveConfig.LOGGING_FREQUENCY) { + WarpDrive.logger.info(this + " Camera frequency set from " + cameraFrequency + " to " + parCameraFrequency); + } cameraFrequency = parCameraFrequency; // force update through main thread since CC runs on server as // 'client' diff --git a/src/main/java/cr0s/warpdrive/block/building/TileEntityShipScanner.java b/src/main/java/cr0s/warpdrive/block/building/TileEntityShipScanner.java index f81f5ccb..f647e7b1 100644 --- a/src/main/java/cr0s/warpdrive/block/building/TileEntityShipScanner.java +++ b/src/main/java/cr0s/warpdrive/block/building/TileEntityShipScanner.java @@ -473,10 +473,13 @@ public class TileEntityShipScanner extends TileEntityAbstractEnergy { jb.blockNBT = tileEntities[index]; if (jb.block != null) { - if (tileEntities[index] == null) { - WarpDrive.debugPrint("[ShipScanner] Adding block to deploy: " + jb.block.getUnlocalizedName() + " (no tile entity)"); - } else { - WarpDrive.debugPrint("[ShipScanner] Adding block to deploy: " + jb.block.getUnlocalizedName() + " with tile entity " + tileEntities[index].getString("id")); + + if (WarpDriveConfig.LOGGING_BUILDING) { + if (tileEntities[index] == null) { + WarpDrive.logger.info("[ShipScanner] Adding block to deploy: " + jb.block.getUnlocalizedName() + " (no tile entity)"); + } else { + WarpDrive.logger.info("[ShipScanner] Adding block to deploy: " + jb.block.getUnlocalizedName() + " with tile entity " + tileEntities[index].getString("id")); + } } blocksToDeploy[index] = jb; diff --git a/src/main/java/cr0s/warpdrive/block/collection/TileEntityLaserTreeFarm.java b/src/main/java/cr0s/warpdrive/block/collection/TileEntityLaserTreeFarm.java index e3bd84e8..2bc236aa 100644 --- a/src/main/java/cr0s/warpdrive/block/collection/TileEntityLaserTreeFarm.java +++ b/src/main/java/cr0s/warpdrive/block/collection/TileEntityLaserTreeFarm.java @@ -103,7 +103,9 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner { if (block.isAssociatedBlock(Block.getBlockFromItem(WarpDriveConfig.IC2_rubberWood.getItem()))) { int metadata = worldObj.getBlockMetadata(pos.intX(), pos.intY(), pos.intZ()); if (metadata >= 2 && metadata <= 5) { - WarpDrive.debugPrint("wetspot found"); + if (WarpDriveConfig.LOGGING_COLLECTION) { + WarpDrive.logger.info("wetspot found"); + } if (consumeEnergyFromBooster(cost, false)) { ItemStack resin = WarpDriveConfig.IC2_Resin.copy(); resin.stackSize = (int) Math.round(Math.random() * 4); @@ -154,7 +156,9 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner { } private static void addTree(LinkedList list, Vector3 newTree) { - WarpDrive.debugPrint("Adding tree position:" + newTree.x + "," + newTree.y + "," + newTree.z); + if (WarpDriveConfig.LOGGING_COLLECTION) { + WarpDrive.logger.info("Adding tree position:" + newTree.x + "," + newTree.y + "," + newTree.z); + } list.add(newTree); } diff --git a/src/main/java/cr0s/warpdrive/block/collection/TileEntityMiningLaser.java b/src/main/java/cr0s/warpdrive/block/collection/TileEntityMiningLaser.java index 55f3f2f1..a01899f1 100644 --- a/src/main/java/cr0s/warpdrive/block/collection/TileEntityMiningLaser.java +++ b/src/main/java/cr0s/warpdrive/block/collection/TileEntityMiningLaser.java @@ -251,7 +251,9 @@ public class TileEntityMiningLaser extends TileEntityAbstractInterfaced { for (ItemStack stack : stacks) { qtyLeft = putInChest(findChest(), stack); if (qtyLeft > 0) { - WarpDrive.debugPrint("" + this + " Overflow detected"); + if (WarpDriveConfig.LOGGING_COLLECTION) { + WarpDrive.logger.info(this + " Overflow detected"); + } overflow = true; int transfer; while (qtyLeft > 0) { diff --git a/src/main/java/cr0s/warpdrive/block/detection/TileEntityCamera.java b/src/main/java/cr0s/warpdrive/block/detection/TileEntityCamera.java index 9a6d1c3c..f458c3fb 100644 --- a/src/main/java/cr0s/warpdrive/block/detection/TileEntityCamera.java +++ b/src/main/java/cr0s/warpdrive/block/detection/TileEntityCamera.java @@ -9,6 +9,7 @@ import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Optional; import cr0s.warpdrive.WarpDrive; import cr0s.warpdrive.block.TileEntityAbstractInterfaced; +import cr0s.warpdrive.conf.WarpDriveConfig; import cr0s.warpdrive.network.PacketHandler; import dan200.computercraft.api.lua.ILuaContext; import dan200.computercraft.api.peripheral.IComputerAccess; @@ -58,7 +59,9 @@ public class TileEntityCamera extends TileEntityAbstractInterfaced { public void setFrequency(int parFrequency) { if (frequency != parFrequency) { frequency = parFrequency; - WarpDrive.debugPrint("" + this + " Camera frequency set to " + frequency); + if (WarpDriveConfig.LOGGING_FREQUENCY) { + WarpDrive.logger.info(this + " Camera frequency set to " + frequency); + } // force update through main thread since CC runs on server as 'client' packetSendTicks = 0; registryUpdateTicks = 0; diff --git a/src/main/java/cr0s/warpdrive/block/detection/TileEntityCloakingCore.java b/src/main/java/cr0s/warpdrive/block/detection/TileEntityCloakingCore.java index 4c749aaa..82d4cc29 100644 --- a/src/main/java/cr0s/warpdrive/block/detection/TileEntityCloakingCore.java +++ b/src/main/java/cr0s/warpdrive/block/detection/TileEntityCloakingCore.java @@ -90,7 +90,9 @@ public class TileEntityCloakingCore extends TileEntityAbstractEnergy { isCloaking = WarpDrive.cloaks.isAreaExists(worldObj, xCoord, yCoord, zCoord); if (!isEnabled) {// disabled if (isCloaking) {// disabled, cloaking => stop cloaking - WarpDrive.debugPrint("" + this + " Disabled, cloak field going down..."); + if (WarpDriveConfig.LOGGING_CLOAKING) { + WarpDrive.logger.info("" + this + " Disabled, cloak field going down..."); + } disableCloakingField(); } else {// disabled, no cloaking // IDLE @@ -113,14 +115,18 @@ public class TileEntityCloakingCore extends TileEntityAbstractEnergy { if (area != null) { area.sendCloakPacketToPlayersEx(false); // recloak field } else { - WarpDrive.debugPrint("getCloakedArea1 returned null for " + worldObj + " " + xCoord + "," + yCoord + "," + zCoord); + if (WarpDriveConfig.LOGGING_CLOAKING) { + WarpDrive.logger.info("getCloakedArea1 returned null for " + worldObj + " " + xCoord + "," + yCoord + "," + zCoord); + } } } else {// enabled, not cloaking but not able to // IDLE } } else {// enabled & cloaked if (!isValid) {// enabled, cloaking but invalid - WarpDrive.debugPrint("" + this + " Coil(s) lost, cloak field is collapsing..."); + if (WarpDriveConfig.LOGGING_CLOAKING) { + WarpDrive.logger.info("" + this + " Coil(s) lost, cloak field is collapsing..."); + } consumeAllEnergy(); disableCloakingField(); } else {// enabled, cloaking and valid @@ -131,11 +137,15 @@ public class TileEntityCloakingCore extends TileEntityAbstractEnergy { if (area != null) { area.sendCloakPacketToPlayersEx(false); // recloak field } else { - WarpDrive.debugPrint("getCloakedArea2 returned null for " + worldObj + " " + xCoord + "," + yCoord + "," + zCoord); + if (WarpDriveConfig.LOGGING_CLOAKING) { + WarpDrive.logger.info("getCloakedArea2 returned null for " + worldObj + " " + xCoord + "," + yCoord + "," + zCoord); + } } setCoilsState(true); } else {// loosing power - WarpDrive.debugPrint("" + this + " Low power, cloak field is collapsing..."); + if (WarpDriveConfig.LOGGING_CLOAKING) { + WarpDrive.logger.info("" + this + " Low power, cloak field is collapsing..."); + } disableCloakingField(); } } @@ -323,7 +333,9 @@ public class TileEntityCloakingCore extends TileEntityAbstractEnergy { // check validity and save new coil position if (newCoilDistance <= 0) { outerCoilsDistance[direction] = 0; - WarpDrive.debugPrint("Invalid outercoil assembly at " + direction); + if (WarpDriveConfig.LOGGING_CLOAKING) { + WarpDrive.logger.info("Invalid outercoil assembly at " + direction); + } return false; } outerCoilsDistance[direction] = newCoilDistance; diff --git a/src/main/java/cr0s/warpdrive/block/detection/TileEntityMonitor.java b/src/main/java/cr0s/warpdrive/block/detection/TileEntityMonitor.java index 56098a9a..7b5ed3cb 100644 --- a/src/main/java/cr0s/warpdrive/block/detection/TileEntityMonitor.java +++ b/src/main/java/cr0s/warpdrive/block/detection/TileEntityMonitor.java @@ -8,6 +8,7 @@ import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Optional; import cr0s.warpdrive.WarpDrive; import cr0s.warpdrive.block.TileEntityAbstractInterfaced; +import cr0s.warpdrive.conf.WarpDriveConfig; import cr0s.warpdrive.network.PacketHandler; import dan200.computercraft.api.lua.ILuaContext; import dan200.computercraft.api.peripheral.IComputerAccess; @@ -47,7 +48,9 @@ public class TileEntityMonitor extends TileEntityAbstractInterfaced { public void setFrequency(int parFrequency) { if (frequency != parFrequency) { frequency = parFrequency; - WarpDrive.debugPrint("" + this + " Monitor frequency set to " + frequency); + if (WarpDriveConfig.LOGGING_FREQUENCY) { + WarpDrive.logger.info(this + " Monitor frequency set to " + frequency); + } // force update through main thread since CC runs on server as 'client' packetSendTicks = 0; } diff --git a/src/main/java/cr0s/warpdrive/block/energy/TileEntityEnanReactorCore.java b/src/main/java/cr0s/warpdrive/block/energy/TileEntityEnanReactorCore.java index 8b0f9998..17790dbf 100644 --- a/src/main/java/cr0s/warpdrive/block/energy/TileEntityEnanReactorCore.java +++ b/src/main/java/cr0s/warpdrive/block/energy/TileEntityEnanReactorCore.java @@ -80,8 +80,8 @@ public class TileEntityEnanReactorCore extends TileEntityAbstractEnergy implemen if (containedEnergy > WarpDriveConfig.PR_TICK_TIME * PR_MIN_GENERATION * 100) { double amountToIncrease = WarpDriveConfig.PR_TICK_TIME * Math.max(PR_MIN_INSTABILITY, PR_MAX_INSTABILITY * Math.pow((worldObj.rand.nextDouble() * containedEnergy) / WarpDriveConfig.PR_MAX_ENERGY, 0.1)); - if (WarpDriveConfig.G_DEBUGMODE) { - WarpDrive.debugPrint("InsInc" + amountToIncrease); + if (WarpDriveConfig.LOGGING_ENERGY) { + WarpDrive.logger.info("InsInc" + amountToIncrease); } instabilityValues[side] += amountToIncrease * (isNatural ? 1.0D : 0.25D); } else { @@ -125,9 +125,9 @@ public class TileEntityEnanReactorCore extends TileEntityAbstractEnergy implemen int side = from.ordinal() - 2; - if (WarpDriveConfig.G_DEBUGMODE) { + if (WarpDriveConfig.LOGGING_ENERGY) { if (side == 3) { - WarpDrive.debugPrint("Instability on " + from.toString() + WarpDrive.logger.info("Instability on " + from.toString() + " decreased by " + String.format("%.1f", amountToRemove) + "/" + String.format("%.1f", PR_MAX_LASER_EFFECT) + " after consuming " + amount + "/" + PR_MAX_LASER_ENERGY + " lasersReceived is " + String.format("%.1f", lasersReceived) + " hence nospamFactor is " + nospamFactor); } @@ -149,16 +149,16 @@ public class TileEntityEnanReactorCore extends TileEntityAbstractEnergy implemen * (PR_MIN_GENERATION + PR_MAX_GENERATION * Math.pow(containedEnergy / (double) WarpDriveConfig.PR_MAX_ENERGY, 0.6D))); containedEnergy = Math.min(containedEnergy + amountToGenerate, WarpDriveConfig.PR_MAX_ENERGY); lastGenerationRate = amountToGenerate / WarpDriveConfig.PR_TICK_TIME; - if (WarpDriveConfig.G_DEBUGMODE) { - WarpDrive.debugPrint("Generated " + amountToGenerate); + if (WarpDriveConfig.LOGGING_ENERGY) { + WarpDrive.logger.info("Generated " + amountToGenerate); } } else {// decaying over 20s without producing power, you better have // power for those lasers int amountToDecay = (int) (WarpDriveConfig.PR_TICK_TIME * (1.0D - stabilityOffset) * (PR_MIN_GENERATION + containedEnergy * 0.01D)); containedEnergy = Math.max(0, containedEnergy - amountToDecay); lastGenerationRate = 0; - if (WarpDriveConfig.G_DEBUGMODE) { - WarpDrive.debugPrint("Decayed " + amountToDecay); + if (WarpDriveConfig.LOGGING_ENERGY) { + WarpDrive.logger.info("Decayed " + amountToDecay); } } } @@ -171,8 +171,8 @@ public class TileEntityEnanReactorCore extends TileEntityAbstractEnergy implemen return; } - if (WarpDriveConfig.G_DEBUGMODE) { - WarpDrive.debugPrint("tickCount " + tickCount + " releasedThisTick " + releasedThisTick + " lasersReceived " + lasersReceived + if (WarpDriveConfig.LOGGING_ENERGY) { + WarpDrive.logger.info("tickCount " + tickCount + " releasedThisTick " + releasedThisTick + " lasersReceived " + lasersReceived + " releasedThisCycle " + releasedThisCycle + " containedEnergy " + containedEnergy); } releasedThisTick = 0; @@ -209,7 +209,9 @@ public class TileEntityEnanReactorCore extends TileEntityAbstractEnergy implemen double normalizedEnergy = containedEnergy / (double) WarpDriveConfig.PR_MAX_ENERGY; int radius = (int) Math.round(PR_MAX_EXPLOSION_RADIUS * Math.pow(normalizedEnergy, 0.125)); double c = PR_MAX_EXPLOSION_REMOVAL_CHANCE * Math.pow(normalizedEnergy, 0.125); - WarpDrive.debugPrint(this + " Explosion radius is " + radius + ", Chance of removal is " + c); + if (WarpDriveConfig.LOGGING_ENERGY) { + WarpDrive.logger.info(this + " Explosion radius is " + radius + ", Chance of removal is " + c); + } if (radius > 1) { for (int x = xCoord - radius; x <= xCoord + radius; x++) { for (int y = yCoord - radius; y <= yCoord + radius; y++) { @@ -440,19 +442,19 @@ public class TileEntityEnanReactorCore extends TileEntityAbstractEnergy implemen int capacity = Math.max(0, 2 * lastGenerationRate - releasedThisTick); if (releaseMode == MODE_MANUAL_RELEASE) { result = Math.min(Math.max(0, containedEnergy), capacity); - if (WarpDriveConfig.G_DEBUGMODE) { - WarpDrive.debugPrint("PotentialOutput Manual " + result + " RF (" + convertRFtoInternal(result) + " internal) capacity " + capacity); + if (WarpDriveConfig.LOGGING_ENERGY) { + WarpDrive.logger.info("PotentialOutput Manual " + result + " RF (" + convertRFtoInternal(result) + " internal) capacity " + capacity); } } else if (releaseMode == MODE_RELEASE_ABOVE) { result = Math.min(Math.max(0, containedEnergy - releaseAbove), capacity); - if (WarpDriveConfig.G_DEBUGMODE) { - WarpDrive.debugPrint("PotentialOutput Above " + result + " RF (" + convertRFtoInternal(result) + " internal) capacity " + capacity); + if (WarpDriveConfig.LOGGING_ENERGY) { + WarpDrive.logger.info("PotentialOutput Above " + result + " RF (" + convertRFtoInternal(result) + " internal) capacity " + capacity); } } else if (releaseMode == MODE_RELEASE_AT_RATE) { int remainingRate = Math.max(0, releaseRate - releasedThisTick); result = Math.min(Math.max(0, containedEnergy), Math.min(remainingRate, capacity)); - if (WarpDriveConfig.G_DEBUGMODE) { - WarpDrive.debugPrint("PotentialOutput Rated " + result + " RF (" + convertRFtoInternal(result) + " internal) remainingRate " + remainingRate + " RF/t capacity " + capacity); + if (WarpDriveConfig.LOGGING_ENERGY) { + WarpDrive.logger.info("PotentialOutput Rated " + result + " RF (" + convertRFtoInternal(result) + " internal) remainingRate " + remainingRate + " RF/t capacity " + capacity); } } return convertRFtoInternal(result); @@ -475,8 +477,8 @@ public class TileEntityEnanReactorCore extends TileEntityAbstractEnergy implemen } releasedThisTick += energyOutput_RF; releasedThisCycle += energyOutput_RF; - if (WarpDriveConfig.G_DEBUGMODE) { - WarpDrive.debugPrint("OutputDone " + energyOutput_internal + " (" + energyOutput_RF + " RF)"); + if (WarpDriveConfig.LOGGING_ENERGY) { + WarpDrive.logger.info("OutputDone " + energyOutput_internal + " (" + energyOutput_RF + " RF)"); } } diff --git a/src/main/java/cr0s/warpdrive/block/movement/TileEntityShipController.java b/src/main/java/cr0s/warpdrive/block/movement/TileEntityShipController.java index 76daac87..6391d1b5 100644 --- a/src/main/java/cr0s/warpdrive/block/movement/TileEntityShipController.java +++ b/src/main/java/cr0s/warpdrive/block/movement/TileEntityShipController.java @@ -106,7 +106,9 @@ public class TileEntityShipController extends TileEntityAbstractInterfaced { ShipCoreMode[] modes = ShipCoreMode.values(); if (mode >= 0 && mode <= modes.length) { this.mode = modes[mode]; - WarpDrive.debugPrint(this + " Mode set to " + this.mode + " (" + this.mode.getCode() + ")"); + if (WarpDriveConfig.LOGGING_JUMP) { + WarpDrive.logger.info(this + " Mode set to " + this.mode + " (" + this.mode.getCode() + ")"); + } } } @@ -128,7 +130,7 @@ public class TileEntityShipController extends TileEntityAbstractInterfaced { // Adding random ticks to warmup core.randomWarmupAddition = worldObj.rand.nextInt(WarpDriveConfig.WC_WARMUP_RANDOM_TICKS); } else { - WarpDrive.debugPrint("" + this + " doJump without a core"); + WarpDrive.logger.error(this + " doJump without a core"); } setJumpFlag(true); @@ -234,7 +236,9 @@ public class TileEntityShipController extends TileEntityAbstractInterfaced { * @param jumpFlag the jumpFlag to set */ public void setJumpFlag(boolean jumpFlag) { - WarpDrive.debugPrint("" + this + " setJumpFlag(" + jumpFlag + ")"); + if (WarpDriveConfig.LOGGING_JUMP) { + WarpDrive.logger.info(this + " setJumpFlag(" + jumpFlag + ")"); + } this.jumpFlag = jumpFlag; } @@ -330,7 +334,9 @@ public class TileEntityShipController extends TileEntityAbstractInterfaced { private void setDistance(int distance) { this.distance = Math.max(1, Math.min(WarpDriveConfig.WC_MAX_JUMP_DISTANCE, distance)); - WarpDrive.debugPrint(this + " Jump distance set to " + distance); + if (WarpDriveConfig.LOGGING_JUMP) { + WarpDrive.logger.info(this + " Jump distance set to " + distance); + } } public int getDistance() { @@ -571,7 +577,9 @@ public class TileEntityShipController extends TileEntityAbstractInterfaced { if (argInt0 < 0 || argInt1 < 0 || argInt2 < 0) { return new Integer[] { getFront(), getRight(), getUp() }; } - WarpDrive.debugPrint("Setting positive gabarits: f: " + argInt0 + " r: " + argInt1 + " u: " + argInt2); + if (WarpDriveConfig.LOGGING_JUMP) { + WarpDrive.logger.info("Setting positive gabarits: f: " + argInt0 + " r: " + argInt1 + " u: " + argInt2); + } setFront(argInt0); setRight(argInt1); setUp(argInt2); @@ -593,7 +601,9 @@ public class TileEntityShipController extends TileEntityAbstractInterfaced { if (argInt0 < 0 || argInt1 < 0 || argInt2 < 0) { return new Integer[] { getBack(), getLeft(), getDown() }; } - WarpDrive.debugPrint("Setting negative gabarits: b: " + argInt0 + " l: " + argInt1 + " d: " + argInt2); + if (WarpDriveConfig.LOGGING_JUMP) { + WarpDrive.logger.info("Setting negative gabarits: b: " + argInt0 + " l: " + argInt1 + " d: " + argInt2); + } setBack(argInt0); setLeft(argInt1); setDown(argInt2); @@ -697,7 +707,7 @@ public class TileEntityShipController extends TileEntityAbstractInterfaced { } return new Object[] { core.shipVolume }; } catch (Exception e) { - if (WarpDriveConfig.G_DEBUGMODE) { + if (WarpDriveConfig.LOGGING_JUMP) {// disabled by default to avoid console spam as ship size is checked quite frequently e.printStackTrace(); } return null; diff --git a/src/main/java/cr0s/warpdrive/block/movement/TileEntityShipCore.java b/src/main/java/cr0s/warpdrive/block/movement/TileEntityShipCore.java index bb2b09a5..da68be73 100644 --- a/src/main/java/cr0s/warpdrive/block/movement/TileEntityShipCore.java +++ b/src/main/java/cr0s/warpdrive/block/movement/TileEntityShipCore.java @@ -132,9 +132,9 @@ public class TileEntityShipCore extends TileEntityAbstractEnergy { if (registryUpdateTicks > WarpDriveConfig.WC_CORES_REGISTRY_UPDATE_INTERVAL_SECONDS * 20) { registryUpdateTicks = 0; WarpDrive.shipCores.updateInRegistry(this); - if (WarpDriveConfig.G_DEBUGMODE) { + if (WarpDriveConfig.LOGGING_JUMP) { WarpDrive.shipCores.printRegistry(); - WarpDrive.debugPrint("" + this + " controller is " + controller + ", warmupTime " + warmupTime + ", currentMode " + currentMode + ", jumpFlag " + WarpDrive.logger.info(this + " controller is " + controller + ", warmupTime " + warmupTime + ", currentMode " + currentMode + ", jumpFlag " + (controller == null ? "NA" : controller.isJumpFlag()) + ", cooldownTime " + cooldownTime); } @@ -261,15 +261,17 @@ public class TileEntityShipCore extends TileEntityAbstractEnergy { messageToAllPlayersOnShip(reason.toString()); return; } - if (WarpDriveConfig.G_DEBUGMODE) { - WarpDrive.debugPrint(this + " Giving warp sickness targetWarmup " + targetWarmup + " distance " + controller.getDistance()); + if (WarpDriveConfig.WC_WARMUP_SICKNESS) { + if (WarpDriveConfig.LOGGING_JUMP) { + WarpDrive.logger.info(this + " Giving warp sickness targetWarmup " + targetWarmup + " distance " + controller.getDistance()); + } + makePlayersOnShipDrunk(targetWarmup + WarpDriveConfig.WC_WARMUP_RANDOM_TICKS); } - makePlayersOnShipDrunk(targetWarmup + WarpDriveConfig.WC_WARMUP_RANDOM_TICKS); } if (!soundPlayed && (soundThreshold > warmupTime)) { - if (WarpDriveConfig.G_DEBUGMODE) { - WarpDrive.debugPrint(this + " Playing sound effect '" + soundFile + "' soundThreshold " + soundThreshold + " warmupTime " + warmupTime); + if (WarpDriveConfig.LOGGING_JUMP) { + WarpDrive.logger.info(this + " Playing sound effect '" + soundFile + "' soundThreshold " + soundThreshold + " warmupTime " + warmupTime); } worldObj.playSoundEffect(xCoord + 0.5f, yCoord + 0.5f, zCoord + 0.5f, soundFile, 4F, 1F); soundPlayed = true; @@ -365,8 +367,8 @@ public class TileEntityShipCore extends TileEntityAbstractEnergy { } else { isolationRate = 0.0D; } - if (WarpDriveConfig.G_DEBUGMODE) { - WarpDrive.debugPrint(this + " Isolation updated to " + isolationBlocksCount + " (" + String.format("%.1f", isolationRate * 100) + "%)"); + if (WarpDriveConfig.LOGGING_JUMP) { + WarpDrive.logger.info(this + " Isolation updated to " + isolationBlocksCount + " (" + String.format("%.1f", isolationRate * 100) + "%)"); } } @@ -592,9 +594,11 @@ public class TileEntityShipCore extends TileEntityAbstractEnergy { } } - private boolean isShipInJumpgate(Jumpgate jg, StringBuilder reason) { - AxisAlignedBB aabb = jg.getGateAABB(); - WarpDrive.debugPrint("[TEWarpCore] Jumpgate " + jg.name + " AABB is " + aabb); + private boolean isShipInJumpgate(Jumpgate jumpgate, StringBuilder reason) { + AxisAlignedBB aabb = jumpgate.getGateAABB(); + if (WarpDriveConfig.LOGGING_JUMP) { + WarpDrive.logger.info(this + " Jumpgate " + jumpgate.name + " AABB is " + aabb); + } int countBlocksInside = 0; int countBlocksTotal = 0; @@ -622,15 +626,19 @@ public class TileEntityShipCore extends TileEntityAbstractEnergy { if (shipVolume != 0) { percent = Math.round((((countBlocksInside * 1.0F) / shipVolume) * 100.0F) * 10.0F) / 10.0F; } - if (shipVolume != countBlocksTotal) { - WarpDrive.logger.info(this + " Ship volume has changed from " + shipVolume + " to " + countBlocksTotal + " blocks"); + + if (WarpDriveConfig.LOGGING_JUMP) { + if (shipVolume != countBlocksTotal) { + WarpDrive.logger.info(this + " Ship volume has changed from " + shipVolume + " to " + countBlocksTotal + " blocks"); + } + WarpDrive.logger.info(this + "Ship has " + countBlocksInside + " / " + shipVolume + " blocks (" + percent + "%) in jumpgate '" + jumpgate.name + "'"); } - WarpDrive.debugPrint("Ship has " + countBlocksInside + " / " + shipVolume + " blocks (" + percent + "%) in jumpgate '" + jg.name + "'"); + // At least 80% of ship must be inside jumpgate if (percent > 80F) { return true; } else if (percent <= 0.001) { - reason.append("Ship is not inside a jumpgate. Jump rejected. Nearest jumpgate is " + jg.toNiceString()); + reason.append("Ship is not inside a jumpgate. Jump rejected. Nearest jumpgate is " + jumpgate.toNiceString()); return false; } else { reason.append("Ship is only " + percent + "% inside a jumpgate. Sorry, we'll loose too much crew as is, jump rejected."); @@ -806,7 +814,9 @@ public class TileEntityShipCore extends TileEntityAbstractEnergy { } } - WarpDrive.debugPrint("" + this + " Distance adjusted to " + distance + " blocks."); + if (WarpDriveConfig.LOGGING_JUMP) { + WarpDrive.logger.info(this + " Distance adjusted to " + distance + " blocks."); + } EntityJump jump = new EntityJump(worldObj, xCoord, yCoord, zCoord, dx, dz, this, (currentMode == ShipCoreMode.HYPERSPACE), distance, direction, false, 0, 0, 0); jump.maxX = maxX; diff --git a/src/main/java/cr0s/warpdrive/block/movement/TileEntityTransporter.java b/src/main/java/cr0s/warpdrive/block/movement/TileEntityTransporter.java index a1a764b9..e9734220 100644 --- a/src/main/java/cr0s/warpdrive/block/movement/TileEntityTransporter.java +++ b/src/main/java/cr0s/warpdrive/block/movement/TileEntityTransporter.java @@ -184,7 +184,9 @@ public class TileEntityTransporter extends TileEntityAbstractEnergy implements I if (isLocked) { int count = 0; double ls = getLockStrength(); - WarpDrive.debugPrint("LS:" + getLockStrength()); + if (WarpDriveConfig.LOGGING_TRANSPORTER) { + WarpDrive.logger.info(this + " lock strength " + getLockStrength()); + } ArrayList entitiesToTransport = findEntities(sourceVec, ls); Integer energyReq = energyCost(); if (energyReq == null) { @@ -192,13 +194,17 @@ public class TileEntityTransporter extends TileEntityAbstractEnergy implements I } Vector3 modDest = destVec.clone().translate(centreOnMe); for (Entity ent : entitiesToTransport) { - WarpDrive.debugPrint(this + " Handling entity " + ent.getEntityId()); if (consumeEnergy(energyReq, false)) { - WarpDrive.debugPrint("" + this + " Energy taken"); + if (WarpDriveConfig.LOGGING_TRANSPORTER) { + WarpDrive.logger.info(this + " Transporting entity " + ent.getEntityId()); + } inflictNegativeEffect(ent, ls); transportEnt(ent, modDest); count++; } else { + if (WarpDriveConfig.LOGGING_TRANSPORTER) { + WarpDrive.logger.info(this + " Insufficient energy to transport entity " + ent.getEntityId()); + } break; } } @@ -227,7 +233,10 @@ public class TileEntityTransporter extends TileEntityAbstractEnergy implements I private void inflictNegativeEffect(Entity ent, double lockStrength) { double value = Math.random() + lockStrength; - WarpDrive.debugPrint("TRANSPORTER INFLICTION: " + value); + if (WarpDriveConfig.LOGGING_TRANSPORTER) { + WarpDrive.logger.info(this + " Inflicting negative effect " + value); + } + if (value < 0.1) { ent.attackEntityFrom(teleDam, 1000); } @@ -242,7 +251,9 @@ public class TileEntityTransporter extends TileEntityAbstractEnergy implements I } private double beaconScan(int xV, int yV, int zV) { - WarpDrive.debugPrint("BeaconScan:" + xV + "," + yV + "," + zV); + if (WarpDriveConfig.LOGGING_TRANSPORTER) { + WarpDrive.logger.info(this + "BeaconScan:" + xV + "," + yV + "," + zV); + } double beacon = 0; int beaconCount = 0; int xL = xV - scanDist; @@ -330,11 +341,12 @@ public class TileEntityTransporter extends TileEntityAbstractEnergy implements I if (source != null && dest != null) { double basePower = min(calculatePower(source), calculatePower(dest), calculatePower(source, dest)); beaconEffect = beaconScan(source, dest); - WarpDrive.debugPrint("BEACON:" + beaconEffect); baseLockStrength = basePower; lockStrengthMul = 1; isLocked = true; - WarpDrive.debugPrint(baseLockStrength + "," + getLockStrength()); + if (WarpDriveConfig.LOGGING_TRANSPORTER) { + WarpDrive.logger.info(this + " Beacon effect " + beaconEffect + " Lock strength " + baseLockStrength + "," + getLockStrength()); + } return getLockStrength(); } else { unlock(); @@ -359,21 +371,23 @@ public class TileEntityTransporter extends TileEntityAbstractEnergy implements I private ArrayList findEntities(Vector3 source, double lockStrength) { AxisAlignedBB bb = getAABB(); - WarpDrive.debugPrint("Transporter:" + bb.toString()); + if (WarpDriveConfig.LOGGING_TRANSPORTER) { + WarpDrive.logger.info(this + " Transporter:" + bb.toString()); + } List data = worldObj.getEntitiesWithinAABBExcludingEntity(null, bb); ArrayList output = new ArrayList(data.size()); - for (Object ent : data) { - if (lockStrength >= 1 || worldObj.rand.nextDouble() < lockStrength) {// If - // weak - // lock, - // don't - // transport - WarpDrive.debugPrint("" + this + " Entity '" + ent.toString() + "' found and added"); - if (ent instanceof Entity) { - output.add((Entity) ent); + for (Object entity : data) { + if (lockStrength >= 1 || worldObj.rand.nextDouble() < lockStrength) {// If weak lock, don't transport + if (entity instanceof Entity) { + if (WarpDriveConfig.LOGGING_TRANSPORTER) { + WarpDrive.logger.info(this + " Entity '" + entity.toString() + "' found and added"); + } + output.add((Entity) entity); } } else { - WarpDrive.debugPrint("" + this + " Entity '" + ent.toString() + "' discarded"); + if (WarpDriveConfig.LOGGING_TRANSPORTER) { + WarpDrive.logger.info(this + " Entity '" + entity.toString() + "' discarded"); + } } } return output; @@ -414,16 +428,18 @@ public class TileEntityTransporter extends TileEntityAbstractEnergy implements I } @Override - public ChatComponentText func_151519_b(EntityLivingBase e) { - String mess = ""; - if (e instanceof EntityPlayer || e instanceof EntityPlayerMP) { - mess = ((EntityPlayer) e).getDisplayName() + " was killed by a teleporter malfunction"; + public ChatComponentText func_151519_b(EntityLivingBase entity) { + String message = ""; + if (entity instanceof EntityPlayer || entity instanceof EntityPlayerMP) { + message = ((EntityPlayer) entity).getDisplayName() + " was killed by a teleporter malfunction"; } else { - mess = e.toString() + " was killed by a teleporter malfunction"; + message = entity.toString() + " was killed by a teleporter malfunction"; } - WarpDrive.debugPrint(mess); - return new ChatComponentText(mess); + if (WarpDriveConfig.LOGGING_TRANSPORTER) { + WarpDrive.logger.info(message); + } + return new ChatComponentText(message); } } diff --git a/src/main/java/cr0s/warpdrive/block/weapon/BlockLaserCamera.java b/src/main/java/cr0s/warpdrive/block/weapon/BlockLaserCamera.java index 4c9e7647..16546ab1 100644 --- a/src/main/java/cr0s/warpdrive/block/weapon/BlockLaserCamera.java +++ b/src/main/java/cr0s/warpdrive/block/weapon/BlockLaserCamera.java @@ -14,6 +14,7 @@ import net.minecraft.world.World; import cpw.mods.fml.common.FMLCommonHandler; import cr0s.warpdrive.WarpDrive; import cr0s.warpdrive.block.TileEntityLaser; +import cr0s.warpdrive.conf.WarpDriveConfig; import cr0s.warpdrive.data.CameraRegistryItem; public class BlockLaserCamera extends BlockContainer { @@ -78,7 +79,9 @@ public class BlockLaserCamera extends BlockContainer { int cameraFrequency = ((TileEntityLaser)te).getCameraFrequency(); CameraRegistryItem cam = WarpDrive.instance.cameras.getCamByFrequency(par1World, cameraFrequency); - WarpDrive.debugPrint("cam detected as " + cam); + if (WarpDriveConfig.LOGGING_WEAPON) { + WarpDrive.logger.info("Camera detected as " + cam); + } WarpDrive.addChatMessage(par5EntityPlayer, getLocalizedName() + ": Beam frequency '" + beamFrequency + "' is " + ((beamFrequency < 0) ? "invalid!" : "valid.") + " Camera frequency '" + cameraFrequency + "' is " + ((cam == null) ? "invalid!" : "valid for laser-camera at " + cam.position.chunkPosX + ", " + cam.position.chunkPosY + ", " + cam.position.chunkPosZ)); diff --git a/src/main/java/cr0s/warpdrive/conf/WarpDriveConfig.java b/src/main/java/cr0s/warpdrive/conf/WarpDriveConfig.java index cb1d99ab..7beaca4c 100644 --- a/src/main/java/cr0s/warpdrive/conf/WarpDriveConfig.java +++ b/src/main/java/cr0s/warpdrive/conf/WarpDriveConfig.java @@ -72,14 +72,25 @@ public class WarpDriveConfig { public static final int LUA_SCRIPTS_TEMPLATES = 1; public static final int LUA_SCRIPTS_ALL = 2; public static int G_LUA_SCRIPTS = LUA_SCRIPTS_ALL; - public static boolean G_DEBUGMODE = false; public static String G_SCHEMALOCATION = "warpDrive_schematics"; public static int G_BLOCKS_PER_TICK = 3500; public static boolean G_ENABLE_IC2_RECIPES = true; public static boolean G_ENABLE_VANILLA_RECIPES = false; public static boolean G_ENABLE_TDK_RECIPES = false; - + + // logging + public static boolean LOGGING_JUMP = false; + public static boolean LOGGING_ENERGY = false; + public static boolean LOGGING_EFFECTS = false; + public static boolean LOGGING_CLOAKING = false; + public static boolean LOGGING_FREQUENCY = false; + public static boolean LOGGING_TARGETTING = false; + public static boolean LOGGING_WEAPON = false; + public static boolean LOGGING_BUILDING = false; + public static boolean LOGGING_COLLECTION = false; + public static boolean LOGGING_TRANSPORTER = false; + // Transition planes public static TransitionPlane[] G_TRANSITIONPLANES = null; @@ -102,6 +113,7 @@ public class WarpDriveConfig { public static int WC_CORES_REGISTRY_UPDATE_INTERVAL_SECONDS = 10; public static int WC_ISOLATION_UPDATE_INTERVAL_SECONDS = 10; public static String[] WC_UNLIMITED_PLAYERNAMES = { "notch", "someone" }; + public static boolean WC_WARMUP_SICKNESS = true; // Warp Radar public static int WR_MAX_ENERGY_VALUE = 100000000; // 100kk eU @@ -232,19 +244,13 @@ public class WarpDriveConfig { G_SPACE_WORLDBORDER_BLOCKS = config.get("General", "space_worldborder_blocks", G_SPACE_WORLDBORDER_BLOCKS, "World border applied to hyperspace & space, set to 0 to disable it").getInt(); G_LUA_SCRIPTS = config.get("General", "lua_scripts", G_LUA_SCRIPTS, - "LUA scripts to load when connecting machines: 0 = none, 1 = templates in a subfolder, 2 = ready to roll (templates are still provided)") - .getInt(); - G_DEBUGMODE = config.get("General", "debug_mode", G_DEBUGMODE, "Detailled logs to help debug the mod, enable it before reporting a bug").getBoolean( - false); + "LUA scripts to load when connecting machines: 0 = none, 1 = templates in a subfolder, 2 = ready to roll (templates are still provided)").getInt(); G_SCHEMALOCATION = config.get("General", "schematic_location", G_SCHEMALOCATION, "Folder where to save ship schematics").getString(); G_BLOCKS_PER_TICK = config.get("General", "blocks_per_tick", G_BLOCKS_PER_TICK, - "Number of blocks to move per ticks, too high will cause lag spikes on ship jumping or deployment, too low may break the ship wirings") - .getInt(); + "Number of blocks to move per ticks, too high will cause lag spikes on ship jumping or deployment, too low may break the ship wirings").getInt(); - G_ENABLE_IC2_RECIPES = config.get("General", "enable_ic2_recipes", G_ENABLE_IC2_RECIPES, "Original recipes based on IndustrialCrat2 by Cr0s") - .getBoolean(true); - G_ENABLE_VANILLA_RECIPES = config.get("General", "enable_vanilla_recipes", G_ENABLE_VANILLA_RECIPES, "Vanilla recipes by DarkholmeTenk").getBoolean( - false); + G_ENABLE_IC2_RECIPES = config.get("General", "enable_ic2_recipes", G_ENABLE_IC2_RECIPES, "Original recipes based on IndustrialCrat2 by Cr0s").getBoolean(true); + G_ENABLE_VANILLA_RECIPES = config.get("General", "enable_vanilla_recipes", G_ENABLE_VANILLA_RECIPES, "Vanilla recipes by DarkholmeTenk").getBoolean(false); G_ENABLE_TDK_RECIPES = config .get("General", "enable_TDK_recipes", @@ -252,17 +258,32 @@ public class WarpDriveConfig { "Mixed recipes for TDK packs by Lem'ADEC (currently requires at least AppliedEnergistics, Extracells, AtomicScience, IndustrialCraft2, GraviSuite and ThermalExpansion") .getBoolean(false); + // Logging + LOGGING_JUMP = config.get("Logging", "enable_jump_debugLogs", LOGGING_JUMP, "Detailled jump logs to help debug the mod, enable it before reporting a bug").getBoolean(false); + LOGGING_ENERGY = config.get("Logging", "enable_energy_debugLogs", LOGGING_ENERGY, "Detailled energy logs to help debug the mod, enable it before reporting a bug").getBoolean(false); + if (WarpDrive.VERSION.contains("-dev")) {// disabled in production, for obvious reasons :) + LOGGING_EFFECTS = config.get("Logging", "enable_effects_logs", LOGGING_EFFECTS, "Detailled effects logs to help debug the mod, will spam your console!").getBoolean(false); + LOGGING_CLOAKING = config.get("Logging", "enable_cloaking_logs", LOGGING_CLOAKING, "Detailled cloaking logs to help debug the mod, will spam your console!").getBoolean(false); + LOGGING_FREQUENCY = config.get("Logging", "enable_frequency_logs", LOGGING_FREQUENCY, "Detailled frequency logs to help debug the mod, will spam your console!").getBoolean(false); + LOGGING_TARGETTING = config.get("Logging", "enable_targetting_logs", LOGGING_TARGETTING, "Detailled targetting logs to help debug the mod, will spam your console!").getBoolean(false); + } else { + LOGGING_EFFECTS = false; + LOGGING_CLOAKING = false; + LOGGING_FREQUENCY = false; + LOGGING_TARGETTING = false; + } + LOGGING_WEAPON = config.get("Logging", "enable_weapon_logs", LOGGING_WEAPON, "Detailled weapon logs to help debug the mod, enable it before reporting a bug").getBoolean(false); + LOGGING_BUILDING = config.get("Logging", "enable_building_logs", LOGGING_BUILDING, "Detailled building logs to help debug the mod, enable it before reporting a bug").getBoolean(false); + LOGGING_COLLECTION = config.get("Logging", "enable_collection_logs", LOGGING_COLLECTION, "Detailled collection logs to help debug the mod, enable it before reporting a bug").getBoolean(false); + LOGGING_TRANSPORTER = config.get("Logging", "enable_transporter_logs", LOGGING_TRANSPORTER, "Detailled transporter logs to help debug the mod, enable it before reporting a bug").getBoolean(false); + // TransitionPlane config.addCustomCategoryComment("TransitionPlane", - "Transition planes defines which region in space allows to go to other dimensions, default is overworld with 100k radius.\n" - + "Each plane is square shaped and defined as a list of 7 integers (all measured in blocks, border is the radius from center)"); + "Transition planes defines which region in space allows to go to other dimensions, default is overworld with 100k radius.\n" + + "Each plane is square shaped and defined as a list of 7 integers (all measured in blocks, border is the radius from center)"); String[] transitionNames = { "overworld" }; transitionNames = config.get("TransitionPlane", "names", transitionNames, "this is the list of transition planes defined hereafter").getStringList(); - int[] defaultPlane = { 0, 0, 0, 30000000, 30000000, 0, 0 }; // 30000000 - // is - // Minecraft - // limit for - // SetBlock + int[] defaultPlane = { 0, 0, 0, 30000000, 30000000, 0, 0 }; // 30000000 is Minecraft limit for SetBlock G_TRANSITIONPLANES = new TransitionPlane[transitionNames.length]; int index = 0; for (String name : transitionNames) { @@ -277,7 +298,7 @@ public class WarpDriveConfig { G_TRANSITIONPLANES[index] = newPlane; } // FIXME: check transition planes aren't overlapping - // FIXME: check transition planes have valid dimension id + // FIXME: check transition planes have valid dimension id, and ignore them // Warp Core WC_MAX_ENERGY_VALUE = config.get("WarpCore", "max_energy_value", WC_MAX_ENERGY_VALUE, "Maximum energy storage").getInt(); @@ -300,6 +321,7 @@ public class WarpDriveConfig { .getInt(); WC_WARMUP_LONGJUMP_SECONDS = config.get("WarpCore", "warmup_longjump_seconds", WC_WARMUP_LONGJUMP_SECONDS, "Long jump means more than 50 blocks") .getInt(); + WC_WARMUP_SICKNESS = config.get("WarpCore", "warmup_sickness", true, "Enable warp sickness during warmup").getBoolean(true); WC_CORES_REGISTRY_UPDATE_INTERVAL_SECONDS = config.get("WarpCore", "cores_registry_update_interval", WC_CORES_REGISTRY_UPDATE_INTERVAL_SECONDS, "(measured in seconds)").getInt(); @@ -543,21 +565,21 @@ public class WarpDriveConfig { ArrayList item = OreDictionary.getOres(oreName); for (ItemStack i : item) { minerOres.add(Block.getBlockFromItem(i.getItem())); - WarpDrive.debugPrint("WD: Added ore ID: " + i); + WarpDrive.logger.info("Added ore ID: " + i); } } if (lowerOreName.contains("log")) { ArrayList item = OreDictionary.getOres(oreName); for (ItemStack i : item) { minerLogs.add(Block.getBlockFromItem(i.getItem())); - WarpDrive.debugPrint("WD: Added log ID: " + i); + WarpDrive.logger.info("Added log ID: " + i); } } if (lowerOreName.contains("leave") || lowerOreName.contains("leaf")) { ArrayList item = OreDictionary.getOres(oreName); for (ItemStack i : item) { minerLeaves.add(Block.getBlockFromItem(i.getItem())); - WarpDrive.debugPrint("WD: Added leaf ID: " + i); + WarpDrive.logger.info("Added leaf ID: " + i); } } } @@ -572,7 +594,7 @@ public class WarpDriveConfig { forgeMultipart_tileMultipart_onChunkLoad = forgeMultipart_tileMultipart.getDeclaredMethod("onChunkLoad"); } catch (Exception e) { isForgeMultipartLoaded = false; - WarpDrive.debugPrint("WarpDriveConfig Error loading ForgeMultipart classes"); + WarpDrive.logger.error("WarpDriveConfig Error loading ForgeMultipart classes"); e.printStackTrace(); } } diff --git a/src/main/java/cr0s/warpdrive/data/CamerasRegistry.java b/src/main/java/cr0s/warpdrive/data/CamerasRegistry.java index bbfe2295..cc40a27d 100644 --- a/src/main/java/cr0s/warpdrive/data/CamerasRegistry.java +++ b/src/main/java/cr0s/warpdrive/data/CamerasRegistry.java @@ -7,6 +7,7 @@ import net.minecraft.block.Block; import net.minecraft.world.ChunkPosition; import net.minecraft.world.World; import cr0s.warpdrive.WarpDrive; +import cr0s.warpdrive.conf.WarpDriveConfig; public class CamerasRegistry { private LinkedList registry; @@ -23,8 +24,10 @@ public class CamerasRegistry { if (isCamAlive(worldObj, cam)) { return cam; } else { - WarpDrive.debugPrint("Removing 'dead' camera at " + cam.position.chunkPosX + ", " + cam.position.chunkPosY + ", " + cam.position.chunkPosZ - + " (while searching)"); + if (WarpDriveConfig.LOGGING_FREQUENCY) { + WarpDrive.logger.info("Removing 'dead' camera at " + + cam.position.chunkPosX + ", " + cam.position.chunkPosY + ", " + cam.position.chunkPosZ + " (while searching)"); + } it.remove(); } } @@ -50,19 +53,23 @@ public class CamerasRegistry { private static boolean isCamAlive(World worldObj, CameraRegistryItem cam) { if (worldObj.provider.dimensionId != cam.dimensionId) { - WarpDrive.debugPrint("Inconsistent worldObj with camera " + worldObj.provider.dimensionId + " vs " + cam.dimensionId); + WarpDrive.logger.error("Inconsistent worldObj with camera " + worldObj.provider.dimensionId + " vs " + cam.dimensionId); return false; } if (!worldObj.getChunkFromBlockCoords(cam.position.chunkPosX, cam.position.chunkPosZ).isChunkLoaded) { - WarpDrive.debugPrint("Reporting an 'unloaded' camera in dimension " + cam.dimensionId + " at " + cam.position.chunkPosX + ", " - + cam.position.chunkPosY + ", " + cam.position.chunkPosZ); + if (WarpDriveConfig.LOGGING_FREQUENCY) { + WarpDrive.logger.info("Reporting an 'unloaded' camera in dimension " + cam.dimensionId + " at " + + cam.position.chunkPosX + ", " + cam.position.chunkPosY + ", " + cam.position.chunkPosZ); + } return false; } Block block = worldObj.getBlock(cam.position.chunkPosX, cam.position.chunkPosY, cam.position.chunkPosZ); if ((block != WarpDrive.blockCamera) && (block != WarpDrive.blockLaserCamera)) { - WarpDrive.debugPrint("Reporting a 'dead' camera in dimension " + cam.dimensionId + " at " + cam.position.chunkPosX + ", " + cam.position.chunkPosY - + ", " + cam.position.chunkPosZ); + if (WarpDriveConfig.LOGGING_FREQUENCY) { + WarpDrive.logger.info("Reporting a 'dead' camera in dimension " + cam.dimensionId + " at " + + cam.position.chunkPosX + ", " + cam.position.chunkPosY + ", " + cam.position.chunkPosZ); + } return false; } @@ -76,8 +83,10 @@ public class CamerasRegistry { for (Iterator it = registry.iterator(); it.hasNext();) { cam = it.next(); if (!isCamAlive(worldObj, cam)) { - WarpDrive.debugPrint("Removing 'dead' camera in dimension " + cam.dimensionId + " at " + cam.position.chunkPosX + ", " + cam.position.chunkPosY - + ", " + cam.position.chunkPosZ); + if (WarpDriveConfig.LOGGING_FREQUENCY) { + WarpDrive.logger.info("Removing 'dead' camera in dimension " + cam.dimensionId + " at " + + cam.position.chunkPosX + ", " + cam.position.chunkPosY + ", " + cam.position.chunkPosZ); + } it.remove(); } } @@ -88,8 +97,10 @@ public class CamerasRegistry { public void removeFromRegistry(World worldObj, ChunkPosition position) { CameraRegistryItem cam = getCamByPosition(worldObj, position); if (cam != null) { - WarpDrive.debugPrint("Removing camera by request in dimension " + cam.dimensionId + " at " + cam.position.chunkPosX + ", " + cam.position.chunkPosY - + ", " + cam.position.chunkPosZ); + if (WarpDriveConfig.LOGGING_FREQUENCY) { + WarpDrive.logger.info("Removing camera by request in dimension " + cam.dimensionId + " at " + + cam.position.chunkPosX + ", " + cam.position.chunkPosY + ", " + cam.position.chunkPosZ); + } registry.remove(cam); } } @@ -103,16 +114,24 @@ public class CamerasRegistry { if (isCamAlive(worldObj, cam)) { CameraRegistryItem existingCam = getCamByPosition(worldObj, cam.position); if (existingCam == null) { - WarpDrive.debugPrint("Adding 'live' camera at " + cam.position.chunkPosX + ", " + cam.position.chunkPosY + ", " + cam.position.chunkPosZ - + " with frequency '" + cam.frequency + "'"); + if (WarpDriveConfig.LOGGING_FREQUENCY) { + WarpDrive.logger.info("Adding 'live' camera at " + + cam.position.chunkPosX + ", " + cam.position.chunkPosY + ", " + cam.position.chunkPosZ + + " with frequency '" + cam.frequency + "'"); + } registry.add(cam); } else if (existingCam.frequency != cam.frequency) { - WarpDrive.debugPrint("Updating 'live' camera at " + cam.position.chunkPosX + ", " + cam.position.chunkPosY + ", " + cam.position.chunkPosZ - + " from frequency '" + existingCam.frequency + "' to frequency '" + cam.frequency + "'"); + if (WarpDriveConfig.LOGGING_FREQUENCY) { + WarpDrive.logger.info("Updating 'live' camera at " + + cam.position.chunkPosX + ", " + cam.position.chunkPosY + ", " + cam.position.chunkPosZ + + " from frequency '" + existingCam.frequency + "' to frequency '" + cam.frequency + "'"); + } existingCam.frequency = cam.frequency; } } else { - WarpDrive.debugPrint("Unable to update 'dead' camera at " + cam.position.chunkPosX + ", " + cam.position.chunkPosY + ", " + cam.position.chunkPosZ); + if (WarpDriveConfig.LOGGING_FREQUENCY) { + WarpDrive.logger.info("Unable to update 'dead' camera at " + cam.position.chunkPosX + ", " + cam.position.chunkPosY + ", " + cam.position.chunkPosZ); + } } } diff --git a/src/main/java/cr0s/warpdrive/data/CloakManager.java b/src/main/java/cr0s/warpdrive/data/CloakManager.java index a9874028..ed892201 100644 --- a/src/main/java/cr0s/warpdrive/data/CloakManager.java +++ b/src/main/java/cr0s/warpdrive/data/CloakManager.java @@ -10,6 +10,7 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; import cpw.mods.fml.common.network.internal.FMLNetworkHandler; import cr0s.warpdrive.WarpDrive; +import cr0s.warpdrive.conf.WarpDriveConfig; import cr0s.warpdrive.network.PacketHandler; /** @@ -95,7 +96,9 @@ public class CloakManager { public static Packet getPacketForThisEntity(Entity e) { if (e.isDead) { - WarpDrive.debugPrint("Fetching addPacket for removed entity"); + if (WarpDriveConfig.LOGGING_CLOAKING) { + WarpDrive.logger.info("Fetching addPacket for removed entity"); + } } Packet pkt = FMLNetworkHandler.getEntitySpawningPacket(e); diff --git a/src/main/java/cr0s/warpdrive/data/CloakedArea.java b/src/main/java/cr0s/warpdrive/data/CloakedArea.java index 98413181..e8946b7c 100644 --- a/src/main/java/cr0s/warpdrive/data/CloakedArea.java +++ b/src/main/java/cr0s/warpdrive/data/CloakedArea.java @@ -11,6 +11,8 @@ import net.minecraft.init.Blocks; import net.minecraft.server.MinecraftServer; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; +import cr0s.warpdrive.WarpDrive; +import cr0s.warpdrive.conf.WarpDriveConfig; import cr0s.warpdrive.network.PacketHandler; public class CloakedArea { @@ -81,7 +83,10 @@ public class CloakedArea { } // Sending only if field changes: sets up or collapsing - public void sendCloakPacketToPlayersEx(boolean decloak) { + public void sendCloakPacketToPlayersEx(final boolean decloak) { + if (WarpDriveConfig.LOGGING_CLOAKING) { + WarpDrive.logger.info("sendCloakPacketToPlayersEx " + decloak); + } final int RADIUS = 250; double midX = this.aabb.minX + (Math.abs(this.aabb.maxX - this.aabb.minX) / 2); diff --git a/src/main/java/cr0s/warpdrive/data/JumpBlock.java b/src/main/java/cr0s/warpdrive/data/JumpBlock.java index 06c63bd2..43d499df 100644 --- a/src/main/java/cr0s/warpdrive/data/JumpBlock.java +++ b/src/main/java/cr0s/warpdrive/data/JumpBlock.java @@ -61,7 +61,9 @@ public class JumpBlock { oldnbt.setInteger("z", newZ); if (oldnbt.hasKey("mainX") && oldnbt.hasKey("mainY") && oldnbt.hasKey("mainZ")) { // Mekanism 6.0.4.44 - WarpDrive.debugPrint("[JUMP] moveBlockSimple: TileEntity from Mekanism detected"); + if (WarpDriveConfig.LOGGING_JUMP) { + WarpDrive.logger.info(this + " moveBlockSimple: TileEntity from Mekanism detected"); + } oldnbt.setInteger("mainX", oldnbt.getInteger("mainX") + offsetX); oldnbt.setInteger("mainY", oldnbt.getInteger("mainY") + offsetY); oldnbt.setInteger("mainZ", oldnbt.getInteger("mainZ") + offsetZ); diff --git a/src/main/java/cr0s/warpdrive/data/ShipCoresRegistry.java b/src/main/java/cr0s/warpdrive/data/ShipCoresRegistry.java index a05daf75..9a49fbba 100644 --- a/src/main/java/cr0s/warpdrive/data/ShipCoresRegistry.java +++ b/src/main/java/cr0s/warpdrive/data/ShipCoresRegistry.java @@ -132,7 +132,7 @@ public class ShipCoresRegistry { } private void removeDeadCores() { - LocalProfiler.start("WarpCoresRegistry Removing dead cores"); + LocalProfiler.start("ShipCoresRegistry Removing dead cores"); TileEntityShipCore c; for (int i = registry.size() - 1; i >= 0; i--) { @@ -140,8 +140,12 @@ public class ShipCoresRegistry { if (c == null || c.getWorldObj() == null || c.getWorldObj().getBlock(c.xCoord, c.yCoord, c.zCoord) != WarpDrive.blockShipCore || c.getWorldObj().getTileEntity(c.xCoord, c.yCoord, c.zCoord) != c || c.getWorldObj().getTileEntity(c.xCoord, c.yCoord, c.zCoord).isInvalid()) { - WarpDrive.debugPrint("Removing 'dead' core at " + ((c != null) ? c.xCoord : "?") + ", " + ((c != null) ? c.yCoord : "?") + ", " - + ((c != null) ? c.zCoord : "?")); + if (WarpDriveConfig.LOGGING_JUMP) { + WarpDrive.logger.info("Removing 'dead' core at " + + ((c != null) ? c.xCoord : "?") + ", " + + ((c != null) ? c.yCoord : "?") + ", " + + ((c != null) ? c.zCoord : "?")); + } registry.remove(i); } } diff --git a/src/main/java/cr0s/warpdrive/item/ItemComponent.java b/src/main/java/cr0s/warpdrive/item/ItemComponent.java index acd3ecb8..a7cf41e4 100644 --- a/src/main/java/cr0s/warpdrive/item/ItemComponent.java +++ b/src/main/java/cr0s/warpdrive/item/ItemComponent.java @@ -54,7 +54,6 @@ public class ItemComponent extends Item implements IAirCanister { } public void registerRecipes() { - WarpDrive.debugPrint("Registering empty recipe"); GameRegistry.addRecipe(new ShapedOreRecipe(getItemStack(0),false,"nrn","r r","nrn", 'r', Items.redstone, 'n', Items.gold_nugget)); @@ -109,7 +108,7 @@ public class ItemComponent extends Item implements IAirCanister { return false; } String data = potentialUnlocalized[is.getItemDamage()]; - WarpDrive.debugPrint(data); + // WarpDrive.logger.info(data); return data.equals(unlocalised); } diff --git a/src/main/java/cr0s/warpdrive/item/ItemHelmet.java b/src/main/java/cr0s/warpdrive/item/ItemHelmet.java index e178f556..2fc92653 100644 --- a/src/main/java/cr0s/warpdrive/item/ItemHelmet.java +++ b/src/main/java/cr0s/warpdrive/item/ItemHelmet.java @@ -10,6 +10,7 @@ import net.minecraft.util.IIcon; import cr0s.warpdrive.WarpDrive; import cr0s.warpdrive.api.IAirCanister; import cr0s.warpdrive.api.IBreathingHelmet; +import cr0s.warpdrive.conf.WarpDriveConfig; public class ItemHelmet extends ItemArmor implements IBreathingHelmet { // private static Random ran = new Random(); @@ -48,7 +49,9 @@ public class ItemHelmet extends ItemArmor implements IBreathingHelmet { @Override public boolean removeAir(Entity player) { - WarpDrive.debugPrint("Checking breathing!"); + if (WarpDriveConfig.G_LOGGING_BREATHING) { + WarpDrive.logger.info("Checking breathing!"); + } if (player instanceof EntityPlayerMP) { EntityPlayerMP pl = (EntityPlayerMP) player; ItemStack[] plInv = pl.inventory.mainInventory; @@ -61,9 +64,7 @@ public class ItemHelmet extends ItemArmor implements IBreathingHelmet { is.stackSize--; ItemStack toAdd = is.copy(); toAdd.stackSize = 1; - toAdd.setItemDamage(is.getItemDamage() + 1); // bypass - // unbreaking - // enchantment + toAdd.setItemDamage(is.getItemDamage() + 1); // bypass unbreaking enchantment if (is.getItemDamage() >= is.getMaxDamage()) { toAdd = airCanister.emptyDrop(is); } @@ -72,9 +73,7 @@ public class ItemHelmet extends ItemArmor implements IBreathingHelmet { pl.worldObj.spawnEntityInWorld(ie); } } else { - is.setItemDamage(is.getItemDamage() + 1); // bypass - // unbreaking - // enchantment + is.setItemDamage(is.getItemDamage() + 1); // bypass unbreaking enchantment if (is.getItemDamage() >= is.getMaxDamage()) { plInv[i] = airCanister.emptyDrop(is); } diff --git a/src/main/java/cr0s/warpdrive/network/BeamEffectMessage.java b/src/main/java/cr0s/warpdrive/network/BeamEffectMessage.java deleted file mode 100644 index eff62e7d..00000000 --- a/src/main/java/cr0s/warpdrive/network/BeamEffectMessage.java +++ /dev/null @@ -1,110 +0,0 @@ -package cr0s.warpdrive.network; - -import net.minecraft.client.Minecraft; -import net.minecraft.world.World; -import io.netty.buffer.ByteBuf; -import cpw.mods.fml.client.FMLClientHandler; -import cpw.mods.fml.common.network.simpleimpl.IMessage; -import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -import cr0s.warpdrive.WarpDrive; -import cr0s.warpdrive.conf.WarpDriveConfig; -import cr0s.warpdrive.data.Vector3; -import cr0s.warpdrive.render.FXBeam; - - -public class BeamEffectMessage implements IMessage, IMessageHandler { - - private Vector3 source; - private Vector3 target; - private float red; - private float green; - private float blue; - private int age; - private int energy; - - public BeamEffectMessage() { - // required on receiving side - } - - public BeamEffectMessage(final Vector3 source, final Vector3 target, final float red, final float green, final float blue, final int age, final int energy) { - this.source = source; - this.target = target; - this.red = red; - this.green = green; - this.blue = blue; - this.age = age; - this.energy = energy; - } - - public BeamEffectMessage( - final double sourceX, final double sourceY, final double sourceZ, - final double targetX, final double targetY, final double targetZ, - final float red, final float green, final float blue, - final int age, final int energy) { - this.source = new Vector3(sourceX, sourceY, sourceZ); - this.target = new Vector3(targetX, targetY, targetZ); - this.red = red; - this.green = green; - this.blue = blue; - this.age = age; - this.energy = energy; - } - - @Override - public void fromBytes(ByteBuf buffer) { - double x = buffer.readDouble(); - double y = buffer.readDouble(); - double z = buffer.readDouble(); - source = new Vector3(x, y, z); - - x = buffer.readDouble(); - y = buffer.readDouble(); - z = buffer.readDouble(); - target = new Vector3(x, y, z); - - red = buffer.readFloat(); - green = buffer.readFloat(); - blue = buffer.readFloat(); - age = buffer.readByte(); - energy = buffer.readInt(); - } - - @Override - public void toBytes(ByteBuf buffer) { - buffer.writeDouble(source.x); - buffer.writeDouble(source.y); - buffer.writeDouble(source.z); - buffer.writeDouble(target.x); - buffer.writeDouble(target.y); - buffer.writeDouble(target.z); - buffer.writeFloat(red); - buffer.writeFloat(green); - buffer.writeFloat(blue); - buffer.writeByte(age); - buffer.writeInt(energy); - } - - private void handle(World worldObj) { - FMLClientHandler.instance().getClient().effectRenderer.addEffect(new FXBeam(worldObj, source.clone(), target.clone(), red, green, blue, age, energy)); - } - - @Override - public IMessage onMessage(BeamEffectMessage beamEffectMessage, MessageContext context) { - // skip in case player just logged in - if (Minecraft.getMinecraft().theWorld == null) { - WarpDrive.logger.error("WorldObj is null, ignoring beam packet"); - return null; - } - - if (WarpDriveConfig.G_DEBUGMODE) { - WarpDrive.debugPrint("Received beam packet from " + beamEffectMessage.source + " to " + beamEffectMessage.target - + " as RGB " + beamEffectMessage.red + " " + beamEffectMessage.green + " " + beamEffectMessage.blue - + " age " + beamEffectMessage.age +" energy " + beamEffectMessage.energy); - } - - beamEffectMessage.handle(Minecraft.getMinecraft().theWorld); - - return null; // no response - } -} diff --git a/src/main/java/cr0s/warpdrive/network/MessageBeamEffect.java b/src/main/java/cr0s/warpdrive/network/MessageBeamEffect.java index c2d9943d..9e9b7bd3 100644 --- a/src/main/java/cr0s/warpdrive/network/MessageBeamEffect.java +++ b/src/main/java/cr0s/warpdrive/network/MessageBeamEffect.java @@ -97,8 +97,8 @@ public class MessageBeamEffect implements IMessage, IMessageHandler list = worldObj.getEntitiesWithinAABBExcludingEntity(player, aabb); @@ -138,8 +142,8 @@ public class MessageCloak implements IMessage, IMessageHandler (" + cloakMessage.maxX + "; " + cloakMessage.maxY + "; " + cloakMessage.maxZ + ")"); } diff --git a/src/main/java/cr0s/warpdrive/network/MessageFrequency.java b/src/main/java/cr0s/warpdrive/network/MessageFrequency.java index f082cfeb..7ac7fddc 100644 --- a/src/main/java/cr0s/warpdrive/network/MessageFrequency.java +++ b/src/main/java/cr0s/warpdrive/network/MessageFrequency.java @@ -80,8 +80,8 @@ public class MessageFrequency implements IMessage, IMessageHandler server) public static void sendLaserTargetingPacket(int x, int y, int z, float yaw, float pitch) { MessageTargeting targetingMessage = new MessageTargeting(x, y, z, yaw, pitch); simpleNetworkManager.sendToServer(targetingMessage); - WarpDrive.debugPrint("Sent targeting packet (" + x + ", " + y + ", " + z + ") yaw " + yaw + " pitch " + pitch); + if (WarpDriveConfig.LOGGING_TARGETTING) { + WarpDrive.logger.info("Sent targeting packet (" + x + ", " + y + ", " + z + ") yaw " + yaw + " pitch " + pitch); + } } // Sending cloaking area definition (server -> client) public static void sendCloakPacket(EntityPlayer player, AxisAlignedBB aabb, int tier, boolean decloak) { MessageCloak cloakMessage = new MessageCloak(aabb, tier, decloak); simpleNetworkManager.sendTo(cloakMessage, (EntityPlayerMP) player); - WarpDrive.debugPrint("Sent cloak packet (aabb " + aabb + ") tier " + tier + " decloak " + decloak); + if (WarpDriveConfig.LOGGING_CLOAKING) { + WarpDrive.logger.info("Sent cloak packet (aabb " + aabb + ") tier " + tier + " decloak " + decloak); + } } } \ No newline at end of file diff --git a/src/main/java/cr0s/warpdrive/render/CameraOverlay.java b/src/main/java/cr0s/warpdrive/render/CameraOverlay.java index e27e1bd3..17d21f26 100644 --- a/src/main/java/cr0s/warpdrive/render/CameraOverlay.java +++ b/src/main/java/cr0s/warpdrive/render/CameraOverlay.java @@ -57,7 +57,7 @@ public class CameraOverlay { float time = Math.abs(frameCount * 2.0F / ANIMATION_FRAMES - 1.0F); int color = (colorGradient(time, 0x40, 0xA0) << 16) + (colorGradient(time, 0x80, 0x00) << 8) + colorGradient(time, 0x80, 0xFF); mc.fontRenderer.drawString(text, (scaledWidth - mc.fontRenderer.getStringWidth(text)) / 2, 30, color, true); - if (WarpDriveConfig.G_DEBUGMODE) { + if (WarpDriveConfig.LOGGING_TARGETTING) { mc.fontRenderer.drawString(WarpDrive.instance.debugMessage, (scaledWidth - mc.fontRenderer.getStringWidth(WarpDrive.instance.debugMessage)) / 2, 40, 0xFF008F, true); } } catch (Exception e) { diff --git a/src/main/java/cr0s/warpdrive/render/ClientCameraUtils.java b/src/main/java/cr0s/warpdrive/render/ClientCameraUtils.java index 177ab349..6ef3dd35 100644 --- a/src/main/java/cr0s/warpdrive/render/ClientCameraUtils.java +++ b/src/main/java/cr0s/warpdrive/render/ClientCameraUtils.java @@ -8,6 +8,7 @@ import net.minecraft.world.World; import org.lwjgl.input.Keyboard; import cr0s.warpdrive.WarpDrive; +import cr0s.warpdrive.conf.WarpDriveConfig; public class ClientCameraUtils { public static EntityPlayer entityPlayer; @@ -39,7 +40,9 @@ public class ClientCameraUtils { check2_z = z2; check2_blockId = block2; - WarpDrive.debugPrint("Setting viewpoint: " + entityCamera.toString()); + if (WarpDriveConfig.LOGGING_WEAPON) { + WarpDrive.logger.info("Setting viewpoint: " + entityCamera.toString()); + } mc.renderViewEntity = entityCamera; mc.gameSettings.thirdPersonView = 0; WarpDrive.instance.isOverlayEnabled = true; @@ -52,7 +55,9 @@ public class ClientCameraUtils { if (entityPlayer != null) { mc.renderViewEntity = entityPlayer; entityPlayer = null; - WarpDrive.debugPrint("Resetting viewpoint"); + if (WarpDriveConfig.LOGGING_WEAPON) { + WarpDrive.logger.info("Resetting viewpoint"); + } } else { WarpDrive.logger.error("reseting viewpoint with invalid player entity ?!?"); } diff --git a/src/main/java/cr0s/warpdrive/render/EntityCamera.java b/src/main/java/cr0s/warpdrive/render/EntityCamera.java index d6b1afdb..155795ad 100644 --- a/src/main/java/cr0s/warpdrive/render/EntityCamera.java +++ b/src/main/java/cr0s/warpdrive/render/EntityCamera.java @@ -73,12 +73,12 @@ public final class EntityCamera extends EntityLivingBase { public void onEntityUpdate() { if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { if (player == null || player.isDead) { - WarpDrive.debugPrint("" + this + " Player is null or dead, closing camera..."); + WarpDrive.logger.error(this + " Player is null or dead, closing camera..."); closeCamera(); return; } if (!ClientCameraUtils.isValidContext(worldObj)) { - WarpDrive.debugPrint("" + this + " Invalid context, closing camera..."); + WarpDrive.logger.error(this + " Invalid context, closing camera..."); closeCamera(); return; } diff --git a/src/main/java/cr0s/warpdrive/world/EntitySphereGen.java b/src/main/java/cr0s/warpdrive/world/EntitySphereGen.java index ae50f429..fe27fd82 100644 --- a/src/main/java/cr0s/warpdrive/world/EntitySphereGen.java +++ b/src/main/java/cr0s/warpdrive/world/EntitySphereGen.java @@ -205,7 +205,7 @@ public final class EntitySphereGen extends Entity { } } if (blocks != null) { - WarpDrive.debugPrint("[EntitySphereGen] Saved " + blocks.size() + " blocks (estimated to " + pregenSize + ")"); + WarpDrive.logger.info("[EntitySphereGen] Saved " + blocks.size() + " blocks (estimated to " + pregenSize + ")"); } // LocalProfiler.stop(); } diff --git a/src/main/java/cr0s/warpdrive/world/EntityStarCore.java b/src/main/java/cr0s/warpdrive/world/EntityStarCore.java index 1b275076..bf98f75b 100644 --- a/src/main/java/cr0s/warpdrive/world/EntityStarCore.java +++ b/src/main/java/cr0s/warpdrive/world/EntityStarCore.java @@ -67,8 +67,8 @@ public final class EntityStarCore extends Entity if (!isLogged) { isLogged = true; - WarpDrive.debugPrint(this + ": Capture range: " + MAX_RANGE - + " X: " + xmin + " to " + xmax + " Y: " + ymin + " to " + ymax + " Z: " + zmin + " to " + zmax); + WarpDrive.logger.info(this + " Capture range " + MAX_RANGE + + " X " + xmin + " to " + xmax + " Y " + ymin + " to " + ymax + " Z " + zmin + " to " + zmax); } for (Object o : list) {