Add anvil command to delete all chunks matching a specified biome

This commit is contained in:
Jesse Boyd 2018-07-25 18:26:05 +10:00
parent a00345fd94
commit f5f13ddbe3
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
2 changed files with 48 additions and 1 deletions

View File

@ -33,6 +33,8 @@ import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.command.binding.Switch; import com.sk89q.worldedit.util.command.binding.Switch;
import com.sk89q.worldedit.util.command.parametric.Optional; import com.sk89q.worldedit.util.command.parametric.Optional;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BaseBiome;
import java.io.IOException; import java.io.IOException;
import java.io.RandomAccessFile; import java.io.RandomAccessFile;
import java.util.*; import java.util.*;
@ -285,6 +287,17 @@ public class AnvilCommands {
if (result != null) player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal())); if (result != null) player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal()));
} }
@Command(
aliases = {"deletebiomechunks", },
desc = "Delete chunks matching a specific biome"
)
@CommandPermissions("worldedit.anvil.trimallair")
public void deleteBiome(Player player, String folder, BaseBiome biome, @Switch('u') boolean unsafe) {
DeleteBiomeFilterSimple filter = new DeleteBiomeFilterSimple(biome);
DeleteBiomeFilterSimple result = runWithWorld(player, folder, filter, true, unsafe);
if (result != null) player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal()));
}
@Command( @Command(
aliases = {"trimallair", }, aliases = {"trimallair", },
desc = "Trim all air in the world" desc = "Trim all air in the world"
@ -299,7 +312,7 @@ public class AnvilCommands {
@Command( @Command(
aliases = {"debugfixair", }, aliases = {"debugfixair", },
desc = "debug" desc = "debug - do not use"
) )
@CommandPermissions("worldedit.anvil.debugfixair") @CommandPermissions("worldedit.anvil.debugfixair")
public void debugfixair(Player player, String folder) throws WorldEditException { public void debugfixair(Player player, String folder) throws WorldEditException {
@ -308,6 +321,17 @@ public class AnvilCommands {
if (result != null) player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal())); if (result != null) player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal()));
} }
@Command(
aliases = {"debugfixroads", },
desc = "debug - do not use"
)
@CommandPermissions("worldedit.anvil.debugfixroads")
public void debugfixroads(Player player, String folder) throws WorldEditException {
DebugFixP2Roads filter = new DebugFixP2Roads();
DebugFixP2Roads result = runWithWorld(player, folder, filter, true, true);
if (result != null) player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal()));
}
@Command( @Command(
aliases = {"replaceallpattern", "reap", "repallpat"}, aliases = {"replaceallpattern", "reap", "repallpat"},
usage = "<folder> [from-block] <to-pattern>", usage = "<folder> [from-block] <to-pattern>",

View File

@ -0,0 +1,23 @@
package com.boydti.fawe.jnbt.anvil.filters;
import com.boydti.fawe.jnbt.anvil.MCAChunk;
import com.boydti.fawe.jnbt.anvil.MCAFilterCounter;
import com.boydti.fawe.object.number.MutableLong;
import com.sk89q.worldedit.world.biome.BaseBiome;
public class DeleteBiomeFilterSimple extends MCAFilterCounter {
private final int id;
public DeleteBiomeFilterSimple(BaseBiome biome) {
this.id = biome.getId();
}
@Override
public MCAChunk applyChunk(MCAChunk chunk, MutableLong cache) {
if ((chunk.biomes[0] & 0xFF) == id) {
chunk.setDeleted(true);
cache.add(Character.MAX_VALUE);
}
return null;
}
}