3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-14 15:10:05 +01:00

Added a command to set biomes. Currently requires a relog for the changes to be visible clientside and is not preserved between chunk regenerations

Dieser Commit ist enthalten in:
zml2008 2012-03-20 23:40:35 -07:00
Ursprung 0702a0f0ac
Commit 34c366d852

Datei anzeigen

@ -31,7 +31,6 @@ public class BiomeCommands {
aliases = { "biomelist", "biomels" }, aliases = { "biomelist", "biomels" },
usage = "[page]", usage = "[page]",
desc = "Gets all biomes available.", desc = "Gets all biomes available.",
min = 0,
max = 1 max = 1
) )
@CommandPermissions("worldedit.biome.list") @CommandPermissions("worldedit.biome.list")
@ -66,22 +65,20 @@ public class BiomeCommands {
@Command( @Command(
aliases = { "biomeinfo" }, aliases = { "biomeinfo" },
usage = "", flags = "pt",
flags = "ts",
desc = "Get the biome of the targeted block.", desc = "Get the biome of the targeted block.",
help = help =
"Get the biome of the block.\n" + "Get the biome of the block.\n" +
"By default use the block you are currently in.\n" + "By default use all the blocks contained in your selection.\n" +
"-t use the block you are looking at.\n" + "-t use the block you are looking at.\n" +
"-s use all the blocks contained in your selection", "-p use the block you are currently in",
min = 0,
max = 0 max = 0
) )
@CommandPermissions("worldedit.biome.info") @CommandPermissions("worldedit.biome.info")
public void biomeInfo(CommandContext args, LocalSession session, LocalPlayer player, public void biomeInfo(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException { EditSession editSession) throws WorldEditException {
if (args.hasFlag('s')) { if (!args.hasFlag('l')) {
LocalWorld world = player.getWorld(); LocalWorld world = player.getWorld();
Region region = session.getSelection(world); Region region = session.getSelection(world);
Set<BiomeType> biomes = new HashSet<BiomeType>(); Set<BiomeType> biomes = new HashSet<BiomeType>();
@ -116,4 +113,50 @@ public class BiomeCommands {
player.print("Biome: " + biome.getName()); player.print("Biome: " + biome.getName());
} }
} }
@Command(
aliases = { "/setbiome" },
usage = "<biome>",
flags = "p",
desc = "Sets the biome of the player's current block or region.",
help =
"Set the biome of the region.\n" +
"By default use all the blocks contained in your selection.\n" +
"-p use the block you are currently in",
min = 1,
max = 1
)
@CommandPermissions("worldedit.biome.set")
public void setBiome(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
final BiomeType target = we.getServer().getBiomes().get(args.getString(0));
if (!args.hasFlag('l')) {
int affected = 0;
LocalWorld world = player.getWorld();
Region region = session.getSelection(world);
if (region instanceof FlatRegion) {
for (Vector2D pt : ((FlatRegion) region).asFlatRegion()) {
world.setBiome(pt, target);
++affected;
}
} else {
HashSet<Long> alreadyVisited = new HashSet<Long>();
for (Vector pt : region) {
if (!alreadyVisited.contains((long)pt.getBlockX() << 32 | pt.getBlockZ() & 0xFFFFFFFFL)) {
alreadyVisited.add(((long)pt.getBlockX() << 32 | pt.getBlockZ() & 0xFFFFFFFFL));
world.setBiome(pt.toVector2D(), target);
++affected;
}
}
}
player.print("Biome changed to " + target.getName() + ". " + affected + " columns affected.");
} else {
Vector2D pos = player.getPosition().toVector2D();
player.getWorld().setBiome(pos, target);
player.print("Biome changed to " + target.getName() + " at your current location.");
}
}
} }