use of com.sk89q.worldedit.regions.selector.ExtendingCuboidRegionSelector in project FastAsyncWorldEdit by IntellectualSites.
the class SelectionCommands method chunk.
@Command(name = "/chunk", desc = "Set the selection to your current chunk.", descFooter = "This command selects 256-block-tall areas,\nwhich can be specified by the y-coordinate.\nE.g. -c x,1,z will select from y=256 to y=511.")
@Logging(POSITION)
@CommandPermissions("worldedit.selection.chunk")
public void chunk(Actor actor, World world, LocalSession session, @Arg(desc = "The chunk to select", def = "") BlockVector3 coordinates, @Switch(name = 's', desc = "Expand your selection to encompass all chunks that are part of it") boolean expandSelection, @Switch(name = 'c', desc = "Use chunk coordinates instead of block coordinates") boolean useChunkCoordinates) throws WorldEditException {
final BlockVector3 min;
final BlockVector3 max;
if (expandSelection) {
Region region = session.getSelection(world);
int minChunkY = world.getMinY() >> CHUNK_SHIFTS_Y;
int maxChunkY = world.getMaxY() >> CHUNK_SHIFTS_Y;
BlockVector3 minChunk = ChunkStore.toChunk3d(region.getMinimumPoint()).clampY(minChunkY, maxChunkY);
BlockVector3 maxChunk = ChunkStore.toChunk3d(region.getMaximumPoint()).clampY(minChunkY, maxChunkY);
min = minChunk.shl(CHUNK_SHIFTS, CHUNK_SHIFTS_Y, CHUNK_SHIFTS);
max = maxChunk.shl(CHUNK_SHIFTS, CHUNK_SHIFTS_Y, CHUNK_SHIFTS).add(15, 255, 15);
actor.print(Caption.of("worldedit.chunk.selected-multiple", TextComponent.of(minChunk.getBlockX()), TextComponent.of(minChunk.getBlockY()), TextComponent.of(minChunk.getBlockZ()), TextComponent.of(maxChunk.getBlockX()), TextComponent.of(maxChunk.getBlockY()), TextComponent.of(maxChunk.getBlockZ())));
} else {
BlockVector3 minChunk;
if (coordinates != null) {
// coords specified
minChunk = useChunkCoordinates ? coordinates : ChunkStore.toChunk3d(coordinates);
} else {
// use player loc
if (actor instanceof Locatable) {
minChunk = ChunkStore.toChunk3d(((Locatable) actor).getBlockLocation().toVector().toBlockPoint());
} else {
throw new StopExecutionException(TextComponent.of("A player or coordinates are required."));
}
}
min = minChunk.shl(CHUNK_SHIFTS, CHUNK_SHIFTS_Y, CHUNK_SHIFTS);
max = min.add(15, 255, 15);
actor.print(Caption.of("worldedit.chunk.selected", TextComponent.of(minChunk.getBlockX()), TextComponent.of(minChunk.getBlockY()), TextComponent.of(minChunk.getBlockZ())));
}
final CuboidRegionSelector selector;
if (session.getRegionSelector(world) instanceof ExtendingCuboidRegionSelector) {
selector = new ExtendingCuboidRegionSelector(world);
} else {
selector = new CuboidRegionSelector(world);
}
selector.selectPrimary(min, ActorSelectorLimits.forActor(actor));
selector.selectSecondary(max, ActorSelectorLimits.forActor(actor));
session.setRegionSelector(world, selector);
session.dispatchCUISelection(actor);
}
use of com.sk89q.worldedit.regions.selector.ExtendingCuboidRegionSelector in project FastAsyncWorldEdit by IntellectualSites.
the class SelectionCommands method select.
@Command(name = "/sel", aliases = { ";", "/desel", "/deselect" }, desc = "Choose a region selector")
// FAWE start
@CommandPermissions("worldedit.analysis.sel")
public // FAWE end
void select(Actor actor, World world, LocalSession session, @Arg(desc = "Selector to switch to", def = "") SelectorChoice selector, @Switch(name = 'd', desc = "Set default selector") boolean setDefaultSelector) throws WorldEditException {
if (selector == null) {
session.getRegionSelector(world).clear();
session.dispatchCUISelection(actor);
actor.print(Caption.of("worldedit.select.cleared"));
return;
}
final RegionSelector oldSelector = session.getRegionSelector(world);
final RegionSelector newSelector;
switch(selector) {
case CUBOID:
newSelector = new CuboidRegionSelector(oldSelector);
actor.print(Caption.of("worldedit.select.cuboid.message"));
break;
case EXTEND:
newSelector = new ExtendingCuboidRegionSelector(oldSelector);
actor.print(Caption.of("worldedit.select.extend.message"));
break;
case POLY:
{
newSelector = new Polygonal2DRegionSelector(oldSelector);
actor.print(Caption.of("worldedit.select.poly.message"));
Optional<Integer> limit = ActorSelectorLimits.forActor(actor).getPolygonVertexLimit();
limit.ifPresent(integer -> actor.print(Caption.of("worldedit.select.poly.limit-message", TextComponent.of(integer))));
break;
}
case ELLIPSOID:
newSelector = new EllipsoidRegionSelector(oldSelector);
actor.print(Caption.of("worldedit.select.ellipsoid.message"));
break;
case SPHERE:
newSelector = new SphereRegionSelector(oldSelector);
actor.print(Caption.of("worldedit.select.sphere.message"));
break;
case CYL:
newSelector = new CylinderRegionSelector(oldSelector);
actor.print(Caption.of("worldedit.select.cyl.message"));
break;
case CONVEX:
case HULL:
case POLYHEDRON:
{
newSelector = new ConvexPolyhedralRegionSelector(oldSelector);
actor.print(Caption.of("worldedit.select.convex.message"));
Optional<Integer> limit = ActorSelectorLimits.forActor(actor).getPolyhedronVertexLimit();
limit.ifPresent(integer -> actor.print(Caption.of("worldedit.select.convex.limit-message", TextComponent.of(integer))));
break;
}
// FAWE start
case POLYHEDRAL:
newSelector = new PolyhedralRegionSelector(world);
actor.print(Caption.of("fawe.selection.sel.convex.polyhedral"));
Optional<Integer> limit = ActorSelectorLimits.forActor(actor).getPolyhedronVertexLimit();
limit.ifPresent(integer -> actor.print(Caption.of("fawe.selection.sel.max", integer)));
actor.print(Caption.of("fawe.selection.sel.list"));
break;
case FUZZY:
case MAGIC:
Mask maskOpt = new IdMask(world);
newSelector = new FuzzyRegionSelector(actor, world, maskOpt);
actor.print(Caption.of("fawe.selection.sel.fuzzy"));
actor.print(Caption.of("fawe.selection.sel.list"));
break;
// FAWE end
case LIST:
default:
CommandListBox box = new CommandListBox("Selection modes", null, null);
box.setHidingHelp(true);
TextComponentProducer contents = box.getContents();
contents.append(SubtleFormat.wrap("Select one of the modes below:")).newline();
box.appendCommand("cuboid", Caption.of("worldedit.select.cuboid.description"), "//sel cuboid");
box.appendCommand("extend", Caption.of("worldedit.select.extend.description"), "//sel extend");
box.appendCommand("poly", Caption.of("worldedit.select.poly.description"), "//sel poly");
box.appendCommand("ellipsoid", Caption.of("worldedit.select.ellipsoid.description"), "//sel ellipsoid");
box.appendCommand("sphere", Caption.of("worldedit.select.sphere.description"), "//sel sphere");
box.appendCommand("cyl", Caption.of("worldedit.select.cyl.description"), "//sel cyl");
box.appendCommand("convex", Caption.of("worldedit.select.convex.description"), "//sel convex");
// FAWE start
box.appendCommand("polyhedral", Caption.of("fawe.selection.sel.polyhedral"), "//sel polyhedral");
box.appendCommand("fuzzy[=<mask>]", Caption.of("fawe.selection.sel.fuzzy-instruction"), "//sel fuzzy[=<mask>]");
box.setComponentsPerPage(box.getComponentsSize());
// FAWE end
actor.print(box.create(1));
return;
}
if (setDefaultSelector) {
RegionSelectorType found = null;
for (RegionSelectorType type : RegionSelectorType.values()) {
if (type.getSelectorClass() == newSelector.getClass()) {
found = type;
break;
}
}
if (found != null) {
session.setDefaultRegionSelector(found);
actor.print(Caption.of("worldedit.select.default-set", TextComponent.of(found.name())));
} else {
throw new RuntimeException("Something unexpected happened. Please report this.");
}
}
session.setRegionSelector(world, newSelector);
session.dispatchCUISelection(actor);
}
Aggregations