@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")); } }
@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")); } }
public static int countDrops( ICommandSender sender, EntityPlayerMP player, HashMap<Chunk, Integer> items, boolean details, boolean kill, boolean killall, float radius, WorldDropsVisitor visitor) { int total = 0; // Iterate over loaded worlds for (WorldServer s : ForgeTools.server.worldServers) { boolean playerInWorld = (player != null) ? s.getWorldInfo().equals(player.worldObj.getWorldInfo()) : false; int worldItemCount = 0; int itemsDeleted = 0; // kill[all] are only relevant for the world the player is currently in if (!playerInWorld && (kill || killall)) continue; // Count entities List loadedEntityList = new ArrayList(s.loadedEntityList); for (int id = 0; id < loadedEntityList.size(); ++id) { Object t = loadedEntityList.get(id); if (t instanceof EntityItem) { EntityItem e = (EntityItem) t; Chunk c = s.getChunkFromBlockCoords((int) Math.round(e.posX), (int) Math.round(e.posZ)); if (!c.isChunkLoaded) continue; ++worldItemCount; if (((kill || killall) && sender != null && sender.getCommandSenderName().equals("Server")) || // Console is sending the command, so no player is needed (playerInWorld && (killall || (kill && e.getDistanceToEntity(player) <= radius)))) // Player wants to kill items around them { e.setDead(); ++itemsDeleted; continue; } if (items.get(c) == null) { items.put(c, 1); } else { items.put(c, items.get(c) + 1); } } } total += worldItemCount; visitor.visit( sender, player, playerInWorld, kill, killall, details, worldItemCount, itemsDeleted, s); } return total; }