@Override
  public void processCommand(ICommandSender sender, String[] params) {
    MinecraftServer server = MinecraftServer.getServer();
    EntityPlayerMP player = getCommandSenderAsPlayer(sender);
    WorldServer world =
        server.worldServerForDimension(player.getEntityWorld().provider.dimensionId);

    if (!TFCOptions.enableDebugMode) {
      TFC_Core.sendInfoMessage(player, new ChatComponentText("Debug Mode Required"));
      return;
    }

    if (params.length == 0) {
      TFC_Core.sendInfoMessage(player, new ChatComponentText("Stripping Chunk"));
      Chunk chunk = world.getChunkFromBlockCoords((int) player.posX, (int) player.posZ);
      for (int x = 0; x < 16; x++) {
        for (int z = 0; z < 16; z++) {
          for (int y = 0; y < 256; y++) {
            Block id = chunk.getBlock(x, y, z);
            if (id != TFCBlocks.Ore
                && id != TFCBlocks.Ore2
                && id != TFCBlocks.Ore3
                && id != Blocks.bedrock)
              world.setBlock(
                  x + (chunk.xPosition * 16), y, z + (chunk.zPosition * 16), Blocks.air, 0, 2);
          }
        }
      }

      TFC_Core.sendInfoMessage(player, new ChatComponentText("Stripping Chunk Complete"));
    } else if (params.length == 1) {
      TFC_Core.sendInfoMessage(
          player,
          new ChatComponentText(
              "Stripping Chunks Within a Radius of " + Integer.parseInt(params[0])));
      int radius = Integer.parseInt(params[0]);
      for (int i = -radius; i <= radius; i++) {
        for (int k = -radius; k <= radius; k++) {
          Chunk chunk =
              world.getChunkFromBlockCoords(
                  (int) player.posX + (i * 16), (int) player.posZ + (k * 16));
          for (int x = 0; x < 16; x++) {
            for (int z = 0; z < 16; z++) {
              for (int y = 0; y < 256; y++) {
                Block id = chunk.getBlock(x, y, z);
                if (id != TFCBlocks.Ore
                    && id != TFCBlocks.Ore2
                    && id != TFCBlocks.Ore3
                    && id != Blocks.bedrock)
                  world.setBlock(
                      x + (chunk.xPosition * 16), y, z + (chunk.zPosition * 16), Blocks.air, 0, 2);
              }
            }
          }
        }
      }

      TFC_Core.sendInfoMessage(player, new ChatComponentText("Stripping Chunk Complete"));
    }
  }
  private int getTopBlock(World world, int x, int z) {
    Chunk chunk = world.getChunkFromBlockCoords(x, z);
    int y = chunk.getTopFilledSegment() + 15;

    int trimmedX = x & 15;
    int trimmedZ = z & 15;

    for (; y > 0; --y) {
      Block block = chunk.getBlock(trimmedX, y, trimmedZ);

      if (block.isAir(world, x, y, z)) {
        continue;
      }

      if (block instanceof BlockStaticLiquid) {
        return y;
      }

      if (block instanceof BlockFluidBase) {
        return y;
      }

      if (block instanceof IFluidBlock) {
        return y;
      }

      if (!block.getMaterial().blocksMovement()) {
        continue;
      }

      if (block instanceof BlockFlower) {
        continue;
      }

      return y - 1;
    }

    return -1;
  }
  @Override
  public void handleCommand(ICommandSender sender, String[] args) {

    if (args.length < 7) {
      sender.addChatMessage(new ChatComponentTranslation("info.cofh.command.syntaxError"));
      throw new WrongUsageException("info.cofh.command." + getCommandName() + ".syntax");
    }
    World world = sender.getEntityWorld();
    if (world.isRemote) {
      return;
    }

    ChunkCoordinates center = null;
    int i = 1;
    int xS, xL;
    if ("@".equals(args[i])) {
      center = sender.getPlayerCoordinates();
      ++i;
      xS = CommandBase.parseInt(sender, args[i++]);
    } else {
      try {
        xS = CommandBase.parseInt(sender, args[i++]);
      } catch (Throwable t) {
        center = CommandBase.getPlayer(sender, args[i - 1]).getPlayerCoordinates();
        xS = CommandBase.parseInt(sender, args[i++]);
      }
    }
    int yS = CommandBase.parseInt(sender, args[i++]), yL;
    int zS = CommandBase.parseInt(sender, args[i++]), zL;
    int t = i + 1;

    try {
      xL = CommandBase.parseInt(sender, args[i++]);
      yL = CommandBase.parseInt(sender, args[i++]);
      zL = CommandBase.parseInt(sender, args[i++]);
    } catch (Throwable e) {
      if (i > t || center == null) {
        throw Throwables.propagate(e);
      }
      --i;
      xL = xS;
      yL = yS;
      zL = zS;
    }

    if (center != null) {
      xS = center.posX - xS;
      yS = center.posY - yS;
      zS = center.posZ - zS;

      xL = center.posX + xL;
      yL = center.posY + yL;
      zL = center.posZ + zL;
    }

    yS &= ~yS >> 31; // max(yS, 0)
    yL &= ~yL >> 31; // max(yL, 0)

    if (xL < xS) {
      t = xS;
      xS = xL;
      xL = t;
    }
    if (yL < yS) {
      t = yS;
      yS = yL;
      yL = t;
    }
    if (zL < zS) {
      t = zS;
      zS = zL;
      zL = t;
    }

    if (yS > 255) {
      sender.addChatMessage(new ChatComponentTranslation("info.cofh.command.syntaxError"));
      sender.addChatMessage(
          new ChatComponentTranslation("info.cofh.command." + getCommandName() + ".syntax"));
      return;
    } else if (yL > 255) {
      yL = 255;
    }

    Block replBlock;
    int replMeta;
    String blockReplRaw;
    {
      int meta = 0;
      String blockRaw = args[i];
      blockReplRaw = blockRaw;
      t = blockRaw.indexOf('#');
      if (t > 0) {
        meta = CommandBase.parseInt(sender, blockRaw.substring(t + 1));
        blockRaw = blockRaw.substring(0, t);
      }
      Block block = Block.getBlockFromName(blockRaw);
      if (block == Blocks.air || meta > 15 || meta < 0) {
        sender.addChatMessage(new ChatComponentTranslation("info.cofh.command.syntaxError"));
        sender.addChatMessage(
            new ChatComponentTranslation("info.cofh.command." + getCommandName() + ".syntax"));
        // TODO: more descriptive error
        return;
      }
      replBlock = block;
      replMeta = meta;
    }

    long blockCounter = ((long) xL - xS) * ((long) yL - yS) * ((long) zL - zS);
    CommandHandler.logAdminCommand(
        sender,
        this,
        "info.cofh.command.replaceblocks.start",
        blockCounter,
        xS,
        yS,
        zS,
        xL,
        yL,
        zL,
        blockReplRaw);

    THashSet<Chunk> set = new THashSet<Chunk>();

    blockCounter = 0;
    for (int e = args.length; i < e; ++i) {
      String blockRaw = args[i];
      if (blockRaw.charAt(0) == '*') {
        if (blockRaw.equals("*fluid")) {
          for (int x = xS; x <= xL; ++x) {
            for (int z = zS; z <= zL; ++z) {
              Chunk chunk = world.getChunkFromBlockCoords(x, z);
              int cX = x & 15, cZ = z & 15;
              for (int y = yS; y <= yL; ++y) {
                Block block = chunk.getBlock(cX, y, cZ);
                if (block.getMaterial().isLiquid()) {
                  if (chunk.func_150807_a(cX, y, cZ, replBlock, replMeta)) {
                    ++blockCounter;
                    set.add(chunk);
                  }
                }
              }
            }
          }
        } else if (blockRaw.equals("*tree")) {
          for (int x = xS; x <= xL; ++x) {
            for (int z = zS; z <= zL; ++z) {
              Chunk chunk = world.getChunkFromBlockCoords(x, z);
              int cX = x & 15, cZ = z & 15;
              for (int y = yS; y <= yL; ++y) {
                Block block = chunk.getBlock(cX, y, cZ);
                if (block.isWood(world, x, y, z) || block.isLeaves(world, x, y, z)) {
                  if (chunk.func_150807_a(cX, y, cZ, replBlock, replMeta)) {
                    ++blockCounter;
                    set.add(chunk);
                  }
                }
              }
            }
          }
        } else if (blockRaw.startsWith("*repl")) {
          for (int x = xS; x <= xL; ++x) {
            for (int z = zS; z <= zL; ++z) {
              Chunk chunk = world.getChunkFromBlockCoords(x, z);
              int cX = x & 15, cZ = z & 15;
              for (int y = yS; y <= yL; ++y) {
                Block block = chunk.getBlock(cX, y, cZ);
                if (block.isReplaceable(world, x, y, z)) {
                  if (chunk.func_150807_a(cX, y, cZ, replBlock, replMeta)) {
                    ++blockCounter;
                    set.add(chunk);
                  }
                }
              }
            }
          }
        } else if (blockRaw.equals("*stone")) {
          for (int x = xS; x <= xL; ++x) {
            for (int z = zS; z <= zL; ++z) {
              Chunk chunk = world.getChunkFromBlockCoords(x, z);
              int cX = x & 15, cZ = z & 15;
              for (int y = yS; y <= yL; ++y) {
                Block block = chunk.getBlock(cX, y, cZ);
                if (block.isReplaceableOreGen(world, x, y, z, Blocks.stone)
                    || block.isReplaceableOreGen(world, x, y, z, Blocks.netherrack)
                    || block.isReplaceableOreGen(world, x, y, z, Blocks.end_stone)) {
                  if (chunk.func_150807_a(cX, y, cZ, replBlock, replMeta)) {
                    ++blockCounter;
                    set.add(chunk);
                  }
                }
              }
            }
          }
        } else if (blockRaw.equals("*rock")) {
          for (int x = xS; x <= xL; ++x) {
            for (int z = zS; z <= zL; ++z) {
              Chunk chunk = world.getChunkFromBlockCoords(x, z);
              int cX = x & 15, cZ = z & 15;
              for (int y = yS; y <= yL; ++y) {
                Block block = chunk.getBlock(cX, y, cZ);
                if (block.getMaterial() == Material.rock) {
                  if (chunk.func_150807_a(cX, y, cZ, replBlock, replMeta)) {
                    ++blockCounter;
                    set.add(chunk);
                  }
                }
              }
            }
          }
        } else if (blockRaw.equals("*sand")) {
          for (int x = xS; x <= xL; ++x) {
            for (int z = zS; z <= zL; ++z) {
              Chunk chunk = world.getChunkFromBlockCoords(x, z);
              int cX = x & 15, cZ = z & 15;
              for (int y = yS; y <= yL; ++y) {
                Block block = chunk.getBlock(cX, y, cZ);
                if (block.getMaterial() == Material.sand) {
                  if (chunk.func_150807_a(cX, y, cZ, replBlock, replMeta)) {
                    ++blockCounter;
                    set.add(chunk);
                  }
                }
              }
            }
          }
        } else if (blockRaw.equals("*dirt")) {
          for (int x = xS; x <= xL; ++x) {
            for (int z = zS; z <= zL; ++z) {
              Chunk chunk = world.getChunkFromBlockCoords(x, z);
              int cX = x & 15, cZ = z & 15;
              for (int y = yS; y <= yL; ++y) {
                Block block = chunk.getBlock(cX, y, cZ);
                Material m = block.getMaterial();
                if (m == Material.grass
                    || m == Material.ground
                    || m == Material.clay
                    || m == Material.snow
                    || m == Material.craftedSnow
                    || m == Material.ice
                    || m == Material.packedIce) {
                  if (chunk.func_150807_a(cX, y, cZ, replBlock, replMeta)) {
                    ++blockCounter;
                    set.add(chunk);
                  }
                }
              }
            }
          }
        } else if (blockRaw.startsWith("*plant")) {
          for (int x = xS; x <= xL; ++x) {
            for (int z = zS; z <= zL; ++z) {
              Chunk chunk = world.getChunkFromBlockCoords(x, z);
              int cX = x & 15, cZ = z & 15;
              for (int y = yS; y <= yL; ++y) {
                Block block = chunk.getBlock(cX, y, cZ);
                Material m = block.getMaterial();
                if (m == Material.plants
                    || m == Material.vine
                    || m == Material.cactus
                    || m == Material.leaves) {
                  if (chunk.func_150807_a(cX, y, cZ, replBlock, replMeta)) {
                    ++blockCounter;
                    set.add(chunk);
                  }
                }
              }
            }
          }
        } else if (blockRaw.equals("*fire")) {
          for (int x = xS; x <= xL; ++x) {
            for (int z = zS; z <= zL; ++z) {
              Chunk chunk = world.getChunkFromBlockCoords(x, z);
              int cX = x & 15, cZ = z & 15;
              for (int y = yS; y <= yL; ++y) {
                Block block = chunk.getBlock(cX, y, cZ);
                Material m = block.getMaterial();
                if (m == Material.fire || m == Material.lava || block.isBurning(world, x, y, z)) {
                  if (chunk.func_150807_a(cX, y, cZ, replBlock, replMeta)) {
                    ++blockCounter;
                    set.add(chunk);
                  }
                }
              }
            }
          }
        }
        continue;
      }
      int meta = -1;
      t = blockRaw.indexOf('#');
      if (t > 0) {
        meta = CommandBase.parseInt(sender, blockRaw.substring(t + 1));
        blockRaw = blockRaw.substring(0, t);
      }
      Block block = Block.getBlockFromName(blockRaw);
      if (block == Blocks.air) {
        continue;
      }

      for (int x = xS; x <= xL; ++x) {
        for (int z = zS; z <= zL; ++z) {
          Chunk chunk = world.getChunkFromBlockCoords(x, z);
          int cX = x & 15, cZ = z & 15;
          for (int y = yS; y <= yL; ++y) {
            boolean v = meta == -1 || chunk.getBlockMetadata(cX, y, cZ) == meta;
            if (v && chunk.getBlock(cX, y, cZ) == block) {
              if (chunk.func_150807_a(cX, y, cZ, replBlock, replMeta)) {
                ++blockCounter;
                set.add(chunk);
              }
            }
          }
        }
      }
    }
    if (!set.isEmpty()) {
      CommandHandler.logAdminCommand(
          sender,
          this,
          "info.cofh.command.replaceblocks.success",
          blockCounter,
          xS,
          yS,
          zS,
          xL,
          yL,
          zL,
          blockReplRaw);
    } else {
      CommandHandler.logAdminCommand(sender, this, "info.cofh.command.replaceblocks.failure");
    }

    if (world instanceof WorldServer) {
      TObjectHashIterator<Chunk> c = set.iterator();
      for (int k = 0, e = set.size(); k < e; ++k) {
        Chunk chunk = c.next();
        PlayerManager manager = ((WorldServer) world).getPlayerManager();
        if (manager == null) {
          return;
        }
        PlayerInstance watcher =
            manager.getOrCreateChunkWatcher(chunk.xPosition, chunk.zPosition, false);
        if (watcher != null) {
          watcher.sendToAllPlayersWatchingChunk(new S21PacketChunkData(chunk, false, -1));
        }
      }
    }
  }
  @SubscribeEvent
  public void onServerTick(ServerTickEvent event) {
    MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
    // Prevent issues when clients switch to LAN servers
    if (server == null) return;

    if (event.phase == Phase.START) {
      if (MapUtil.calculatingMap.get()) MapUtil.BiomeMapNextTick();
      else if (!MapUtil.doneOverworldTexture) MapUtil.makeOverworldTexture();

      if (TickHandlerServer.spaceRaceData == null) {
        World world =
            FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(0);
        TickHandlerServer.spaceRaceData =
            (WorldDataSpaceRaces)
                world.mapStorage.loadData(
                    WorldDataSpaceRaces.class, WorldDataSpaceRaces.saveDataID);

        if (TickHandlerServer.spaceRaceData == null) {
          TickHandlerServer.spaceRaceData = new WorldDataSpaceRaces(WorldDataSpaceRaces.saveDataID);
          world.mapStorage.setData(WorldDataSpaceRaces.saveDataID, TickHandlerServer.spaceRaceData);
        }
      }

      SpaceRaceManager.tick();

      if (TickHandlerServer.tickCount % 100 == 0) {
        WorldServer[] worlds = server.worldServers;

        for (int i = 0; i < worlds.length; i++) {
          WorldServer world = worlds[i];
          ChunkProviderServer chunkProviderServer = world.theChunkProviderServer;

          Map<Long, List<Footprint>> footprintMap =
              TickHandlerServer.serverFootprintMap.get(world.provider.dimensionId);

          if (footprintMap != null) {
            boolean mapChanged = false;

            if (chunkProviderServer != null) {
              Iterator iterator = chunkProviderServer.loadedChunks.iterator();

              while (iterator.hasNext()) {
                Chunk chunk = (Chunk) iterator.next();
                long chunkKey = ChunkCoordIntPair.chunkXZ2Int(chunk.xPosition, chunk.zPosition);

                List<Footprint> footprints = footprintMap.get(chunkKey);

                if (footprints != null) {
                  List<Footprint> toRemove = new ArrayList<Footprint>();

                  for (int j = 0; j < footprints.size(); j++) {
                    footprints.get(j).age += 100;

                    if (footprints.get(j).age >= Footprint.MAX_AGE) {
                      toRemove.add(footprints.get(j));
                    }
                  }

                  if (!toRemove.isEmpty()) {
                    footprints.removeAll(toRemove);
                  }

                  footprintMap.put(chunkKey, footprints);
                  mapChanged = true;

                  GalacticraftCore.packetPipeline.sendToDimension(
                      new PacketSimple(
                          EnumSimplePacket.C_UPDATE_FOOTPRINT_LIST,
                          new Object[] {
                            chunkKey, footprints.toArray(new Footprint[footprints.size()])
                          }),
                      worlds[i].provider.dimensionId);
                }
              }
            }

            if (mapChanged) {
              TickHandlerServer.serverFootprintMap.put(world.provider.dimensionId, footprintMap);
            }
          }
        }
      }

      if (!footprintBlockChanges.isEmpty()) {
        for (BlockVec3Dim targetPoint : footprintBlockChanges) {
          WorldServer[] worlds =
              FMLCommonHandler.instance().getMinecraftServerInstance().worldServers;

          for (int i = 0; i < worlds.length; i++) {
            WorldServer world = worlds[i];

            if (world.provider.dimensionId == targetPoint.dim) {
              long chunkKey =
                  ChunkCoordIntPair.chunkXZ2Int((int) targetPoint.x >> 4, (int) targetPoint.z >> 4);
              GalacticraftCore.packetPipeline.sendToAllAround(
                  new PacketSimple(
                      EnumSimplePacket.C_FOOTPRINTS_REMOVED,
                      new Object[] {
                        chunkKey, new BlockVec3(targetPoint.x, targetPoint.y, targetPoint.z)
                      }),
                  new NetworkRegistry.TargetPoint(
                      targetPoint.dim, targetPoint.x, targetPoint.y, targetPoint.z, 50));

              //                            Map<Long, List<Footprint>> footprintMap =
              // TickHandlerServer.serverFootprintMap.get(world.provider.dimensionId);
              //
              //                            if (footprintMap != null && !footprintMap.isEmpty())
              //                            {
              //                                List<Footprint> footprints =
              // footprintMap.get(chunkKey);
              //                                if (footprints != null)
              //                                	GalacticraftCore.packetPipeline.sendToAllAround(new
              // PacketSimple(EnumSimplePacket.C_UPDATE_FOOTPRINT_LIST, new Object[] { chunkKey,
              // footprints.toArray(new Footprint[footprints.size()]) }), new
              // NetworkRegistry.TargetPoint(targetPoint.dim, targetPoint.x, targetPoint.y,
              // targetPoint.z, 50));
              //                            }
            }
          }
        }

        footprintBlockChanges.clear();
      }

      if (tickCount % 20 == 0) {
        if (!playersRequestingMapData.isEmpty()) {
          ArrayList<EntityPlayerMP> copy = new ArrayList<EntityPlayerMP>(playersRequestingMapData);
          for (EntityPlayerMP playerMP : copy) {
            GCPlayerStats stats = GCPlayerStats.get(playerMP);
            ChunkCoordIntPair chunkCoordIntPair =
                new ChunkCoordIntPair(
                    (int) Math.floor(stats.coordsTeleportedFromX) >> 4,
                    (int) Math.floor(stats.coordsTeleportedFromZ) >> 4);
            BufferedImage image = new BufferedImage(400, 400, BufferedImage.TYPE_INT_RGB);

            for (int x0 = -12; x0 <= 12; x0++) {
              for (int z0 = -12; z0 <= 12; z0++) {
                Chunk chunk =
                    MinecraftServer.getServer()
                        .worldServerForDimension(0)
                        .getChunkFromChunkCoords(
                            chunkCoordIntPair.chunkXPos + x0, chunkCoordIntPair.chunkZPos + z0);

                if (chunk != null) {
                  for (int z = 0; z < 16; z++) {
                    for (int x = 0; x < 16; x++) {
                      int l4 = chunk.getHeightValue(x, z) + 1;
                      Block block = Blocks.air;
                      int i5 = 0;

                      if (l4 > 1) {
                        do {
                          --l4;
                          block = chunk.getBlock(x, l4, z);
                          i5 = chunk.getBlockMetadata(x, l4, z);
                        } while (block.getMapColor(i5) == MapColor.airColor && l4 > 0);
                      }

                      int col = block.getMapColor(i5).colorValue;
                      image.setRGB(x + (x0 + 12) * 16, z + (z0 + 12) * 16, col);
                    }
                  }
                }
              }
            }

            try {
              File baseFolder =
                  new File(
                      MinecraftServer.getServer().worldServerForDimension(0).getChunkSaveLocation(),
                      "galacticraft/overworldMap");

              if (!baseFolder.exists()) {
                if (!baseFolder.mkdirs()) {
                  GCLog.severe(
                      "Base folder(s) could not be created: " + baseFolder.getAbsolutePath());
                }
              }

              File outputFile =
                  new File(
                      baseFolder,
                      ""
                          + chunkCoordIntPair.chunkXPos
                          + "_"
                          + chunkCoordIntPair.chunkZPos
                          + ".jpg");

              if (!outputFile.exists() || (outputFile.canWrite() && outputFile.canRead())) {
                ImageIO.write(image, "jpg", outputFile);
              }
            } catch (IOException e) {
              e.printStackTrace();
            }
          }

          playersRequestingMapData.removeAll(copy);
        }
      }

      TickHandlerServer.tickCount++;

      if (TickHandlerServer.tickCount >= Long.MAX_VALUE) {
        TickHandlerServer.tickCount = 0;
      }

      EnergyNetwork.tickCount++;
    } else if (event.phase == Phase.END) {
      int maxPasses = 10;
      while (!TickHandlerServer.networkTicks.isEmpty()) {
        LinkedList<EnergyNetwork> pass = new LinkedList();
        pass.addAll(TickHandlerServer.networkTicks);
        TickHandlerServer.networkTicks.clear();
        for (EnergyNetwork grid : pass) {
          grid.tickEnd();
        }

        if (--maxPasses <= 0) {
          break;
        }
      }

      maxPasses = 10;
      while (!TickHandlerServer.oxygenTransmitterUpdates.isEmpty()) {
        LinkedList<TileEntityOxygenTransmitter> pass = new LinkedList();
        pass.addAll(TickHandlerServer.oxygenTransmitterUpdates);
        TickHandlerServer.oxygenTransmitterUpdates.clear();
        for (TileEntityOxygenTransmitter newTile : pass) {
          if (!newTile.isInvalid()) newTile.refresh();
        }

        if (--maxPasses <= 0) {
          break;
        }
      }

      maxPasses = 10;
      while (!TickHandlerServer.hydrogenTransmitterUpdates.isEmpty()) {
        LinkedList<TileEntityHydrogenPipe> pass = new LinkedList();
        pass.addAll(TickHandlerServer.hydrogenTransmitterUpdates);
        TickHandlerServer.hydrogenTransmitterUpdates.clear();
        for (TileEntityHydrogenPipe newTile : pass) {
          if (!newTile.isInvalid()) newTile.refresh();
        }

        if (--maxPasses <= 0) {
          break;
        }
      }

      maxPasses = 10;
      while (!TickHandlerServer.energyTransmitterUpdates.isEmpty()) {
        LinkedList<TileBaseConductor> pass = new LinkedList();
        pass.addAll(TickHandlerServer.energyTransmitterUpdates);
        TickHandlerServer.energyTransmitterUpdates.clear();
        for (TileBaseConductor newTile : pass) {
          if (!newTile.isInvalid()) newTile.refresh();
        }

        if (--maxPasses <= 0) {
          break;
        }
      }
    }
  }
  @Override
  public void processCommand(ICommandSender sender, String[] params) {
    EntityPlayerMP player = getCommandSenderAsPlayer(sender);

    if (!TFCOptions.enableDebugMode) {
      TFC_Core.sendInfoMessage(player, new ChatComponentText("Debug Mode Required"));
      return;
    }

    MinecraftServer server = MinecraftServer.getServer();
    WorldServer world =
        server.worldServerForDimension(player.getEntityWorld().provider.dimensionId);
    if (params.length == 0) {
      TFC_Core.sendInfoMessage(player, new ChatComponentText("Stripping Chunk"));
      Chunk chunk = world.getChunkFromBlockCoords((int) player.posX, (int) player.posZ);
      for (int x = 0; x < 16; x++) {
        for (int z = 0; z < 16; z++) {
          for (int y = 0; y < 256; y++) {
            Block id = chunk.getBlock(x, y, z);
            if (id != Blocks.air
                && id != TFCBlocks.ore
                && id != TFCBlocks.ore2
                && id != TFCBlocks.ore3
                && id != Blocks.bedrock) {
              if (TFC_Core.isGround(
                  id)) // Automatically replace ground blocks to help with performance
              {
                world.setBlock(
                    x + (chunk.xPosition * 16), y, z + (chunk.zPosition * 16), Blocks.air, 0, 2);
              } else {
                Boolean isOre = false;
                Iterator iter = WorldGenOre.oreList.values().iterator();
                while (iter.hasNext()) {
                  OreSpawnData osd = (OreSpawnData) iter.next();
                  if (osd != null && id == osd.block) {
                    isOre = true;
                    break;
                  }
                }

                if (!isOre) {
                  world.setBlock(
                      x + (chunk.xPosition * 16), y, z + (chunk.zPosition * 16), Blocks.air, 0, 2);
                }
              }
            }
          }
        }
      }

      TFC_Core.sendInfoMessage(player, new ChatComponentText("Stripping Chunk Complete"));
    } else if (params.length == 1) {
      TFC_Core.sendInfoMessage(
          player,
          new ChatComponentText(
              "Stripping Chunks Within a Radius of " + Integer.parseInt(params[0])));
      int radius = Integer.parseInt(params[0]);
      for (int i = -radius; i <= radius; i++) {
        for (int k = -radius; k <= radius; k++) {
          Chunk chunk =
              world.getChunkFromBlockCoords((int) player.posX + i * 16, (int) player.posZ + k * 16);
          for (int x = 0; x < 16; x++) {
            for (int z = 0; z < 16; z++) {
              for (int y = 0; y < 256; y++) {
                Block id = chunk.getBlock(x, y, z);
                if (id != Blocks.air
                    && id != TFCBlocks.ore
                    && id != TFCBlocks.ore2
                    && id != TFCBlocks.ore3
                    && id != Blocks.bedrock) {
                  if (TFC_Core.isGround(
                      id)) // Automatically replace ground blocks to help with performance
                  {
                    world.setBlock(
                        x + (chunk.xPosition * 16),
                        y,
                        z + (chunk.zPosition * 16),
                        Blocks.air,
                        0,
                        2);
                  } else {
                    Boolean isOre = false;
                    Iterator iter = WorldGenOre.oreList.values().iterator();
                    while (iter.hasNext()) {
                      OreSpawnData osd = (OreSpawnData) iter.next();
                      if (osd != null && id == osd.block) {
                        isOre = true;
                        break;
                      }
                    }

                    if (!isOre) {
                      world.setBlock(
                          x + (chunk.xPosition * 16),
                          y,
                          z + (chunk.zPosition * 16),
                          Blocks.air,
                          0,
                          2);
                    }
                  }
                }
              }
            }
          }
        }
      }

      TFC_Core.sendInfoMessage(player, new ChatComponentText("Stripping Chunk Complete"));
    }
  }
  @Override
  public void updateEntity() {
    super.updateEntity();

    if (!this.worldObj.isRemote) {
      this.produceOxygen();
      // if (this.getEnergyStored() > 0)
      // {
      // int gasToSend = Math.min(this.storedOxygen,
      // GCCoreTileEntityOxygenCollector.OUTPUT_PER_TICK);
      // GasStack toSend = new GasStack(GalacticraftCore.gasOxygen,
      // gasToSend);
      // this.storedOxygen -= GasTransmission.emitGasToNetwork(toSend,
      // this, this.getOxygenOutputDirection());
      //
      // Vector3 thisVec = new Vector3(this);
      // TileEntity tileEntity =
      // thisVec.modifyPositionFromSide(this.getOxygenOutputDirection()).getTileEntity(this.worldObj);
      //
      // if (tileEntity instanceof IGasAcceptor)
      // {
      // if (((IGasAcceptor)
      // tileEntity).canReceiveGas(this.getOxygenOutputDirection().getOpposite(),
      // GalacticraftCore.gasOxygen))
      // {
      // double sendingGas = 0;
      //
      // if (this.storedOxygen >=
      // GCCoreTileEntityOxygenCollector.OUTPUT_PER_TICK)
      // {
      // sendingGas = GCCoreTileEntityOxygenCollector.OUTPUT_PER_TICK;
      // }
      // else
      // {
      // sendingGas = this.storedOxygen;
      // }
      //
      // this.storedOxygen -= sendingGas - ((IGasAcceptor)
      // tileEntity).receiveGas(new GasStack(GalacticraftCore.gasOxygen,
      // (int) Math.floor(sendingGas)));
      // }
      // }
      // }

      // The later calculations are more efficient if power is a float, so
      // there are fewer casts
      float power = 0;

      if (this.getEnergyStoredGC() > 0) {
        if (this.worldObj.provider instanceof IGalacticraftWorldProvider) {
          // Pre-test to see if close to the map edges, so code
          // doesn't have to continually test for map edges inside the
          // loop
          if (this.xCoord > -29999995
              && this.xCoord < 2999995
              && this.zCoord > -29999995
              && this.zCoord < 29999995) {
            // Test the y coordinates, so code doesn't have to keep
            // testing that either
            int miny = this.yCoord - 5;
            int maxy = this.yCoord + 5;
            if (miny < 0) {
              miny = 0;
            }
            if (maxy >= this.worldObj.getHeight()) {
              maxy = this.worldObj.getHeight() - 1;
            }

            // Loop the x and the z first, so the y loop will be at
            // fixed (x,z) coordinates meaning fixed chunk
            // coordinates
            for (int x = this.xCoord - 5; x <= this.xCoord + 5; x++) {
              int chunkx = x >> 4;
              int intrachunkx = x & 15;
              // Preload the first chunk for the z loop - there
              // can be a maximum of 2 chunks in the z loop
              int chunkz = (this.zCoord - 5) >> 4;
              Chunk chunk = this.worldObj.getChunkFromChunkCoords(chunkx, chunkz);
              for (int z = this.zCoord - 5; z <= this.zCoord + 5; z++) {
                if ((z >> 4) != chunkz) {
                  // moved across z chunk boundary into a new
                  // chunk, so load the new chunk
                  chunkz = z >> 4;
                  chunk = this.worldObj.getChunkFromChunkCoords(chunkx, chunkz);
                }
                for (int y = miny; y <= maxy; y++) {
                  // chunk.getBlockID is like world.getBlock
                  // but faster - needs to be given
                  // intra-chunk coordinates though
                  final Block block = chunk.getBlock(intrachunkx, y, z & 15);
                  // Test for the two most common blocks (air
                  // and breatheable air) without looking up
                  // in the blocksList
                  if (block != Blocks.air && block != GCBlocks.breatheableAir) {
                    if (block.isLeaves(this.worldObj, x, y, z)
                        || block instanceof IPlantable
                            && ((IPlantable) block).getPlantType(this.worldObj, x, y, z)
                                == EnumPlantType.Crop) {
                      power += 0.075F;
                    }
                  }
                }
              }
            }
          }
        } else {
          power = 9.3F;
        }

        power = (float) Math.floor(power);

        this.lastOxygenCollected = power;

        this.storedOxygen = (int) Math.max(Math.min(this.storedOxygen + power, this.maxOxygen), 0);
      } else {
        this.lastOxygenCollected = 0;
      }
    }
  }