@CommandDescription (aliases = {"object", "obj"}, usage = "[-f] <object>", flags = {@Flag (aliases = {"force", "f"})},
desc = "Spawn a WorldGeneratorObject at your location. Use -f to ignore canPlace check")
@Filter (PlayerFilter.class)
@Permissible ("vanilla.command.debug")
public void generateObject(Player player, CommandArguments args) throws CommandException {
final WorldGeneratorObject object = VanillaObjects.byName(args.currentArgument("object"));
if (object == null) {
throw args.failure("object", "Unknown object!", false);
} else {
args.success("object", object);
}
args.assertCompletelyParsed();
final Point loc = player.getPhysics().getPosition();
final World world = loc.getWorld();
final int x = loc.getBlockX();
final int y = loc.getBlockY();
final int z = loc.getBlockZ();
final boolean force = args.has("force");
if (!object.canPlaceObject(world, x, y, z)) {
player.sendMessage("Couldn't place the object.");
if (!force) {
return;
}
player.sendMessage("Forcing placement.");
}
object.placeObject(world, x, y, z);
if (object instanceof RandomizableObject) {
((RandomizableObject) object).randomize();
}
}