use of com.sk89q.worldedit.regions.CylinderRegion in project kit-api by HGLabor.
the class GladiatorKit method getGladiatorLocation.
// one day stackoverflow haha
private Region getGladiatorLocation(Location location, int radius, int height) {
Random random = new Random();
AbstractRegion region = new CylinderRegion(BukkitAdapter.adapt(location.getWorld()), BukkitAdapter.asBlockVector(location), Vector2.at(radius, radius), location.getBlockY(), location.getBlockY() + height);
if (hasEnoughSpace(region)) {
return region;
} else {
return getGladiatorLocation(location.add(random.nextBoolean() ? -10 : 10, 5, random.nextBoolean() ? -10 : 10), radius, height);
}
}
use of com.sk89q.worldedit.regions.CylinderRegion in project FastAsyncWorldEdit by IntellectualSites.
the class AbstractPlayerActor method setSelection.
@Override
public void setSelection(Region region) {
RegionSelector selector;
if (region instanceof ConvexPolyhedralRegion) {
selector = new ConvexPolyhedralRegionSelector((ConvexPolyhedralRegion) region);
} else if (region instanceof CylinderRegion) {
selector = new CylinderRegionSelector((CylinderRegion) region);
} else if (region instanceof Polygonal2DRegion) {
selector = new Polygonal2DRegionSelector((Polygonal2DRegion) region);
} else {
selector = new CuboidRegionSelector(null, region.getMinimumPoint(), region.getMaximumPoint());
}
selector.setWorld(region.getWorld());
getSession().setRegionSelector(getWorld(), selector);
}
use of com.sk89q.worldedit.regions.CylinderRegion in project FastAsyncWorldEdit by IntellectualSites.
the class UtilityCommands method killMatchingEntities.
private int killMatchingEntities(Integer radius, Actor actor, Supplier<EntityFunction> func) throws IncompleteRegionException, MaxChangedBlocksException {
List<EntityVisitor> visitors = new ArrayList<>();
LocalSession session = we.getSessionManager().get(actor);
BlockVector3 center = session.getPlacementPosition(actor);
EditSession editSession = session.createEditSession(actor);
List<? extends Entity> entities;
if (radius >= 0) {
CylinderRegion region = CylinderRegion.createRadius(editSession, center, radius);
entities = editSession.getEntities(region);
} else {
entities = editSession.getEntities();
}
visitors.add(new EntityVisitor(entities.iterator(), func.get()));
int killed = 0;
for (EntityVisitor visitor : visitors) {
Operations.completeLegacy(visitor);
killed += visitor.getAffected();
}
session.remember(editSession);
editSession.close();
return killed;
}
use of com.sk89q.worldedit.regions.CylinderRegion in project FastAsyncWorldEdit by IntellectualSites.
the class UtilityCommands method snow.
@Command(name = "snow", aliases = { "/snow" }, desc = "Simulates snow")
@CommandPermissions("worldedit.snow")
@Logging(PLACEMENT)
public int snow(Actor actor, LocalSession session, EditSession editSession, @Arg(desc = "The radius of the cylinder to snow in", def = "10") double size, @Arg(desc = "The height of the cylinder to snow in", def = HeightConverter.DEFAULT_VALUE) @VertHeight int height, @Switch(name = 's', desc = "Stack snow layers") boolean stack) throws WorldEditException {
size = Math.max(1, size);
height = Math.max(1, height);
we.checkMaxRadius(size);
BlockVector3 position = session.getPlacementPosition(actor);
CylinderRegion region = new CylinderRegion(position, Vector2.at(size, size), position.getBlockY() - height, position.getBlockY() + height);
int affected = editSession.simulateSnow(region, stack);
actor.print(Caption.of("worldedit.snow.created", TextComponent.of(affected)));
return affected;
}
use of com.sk89q.worldedit.regions.CylinderRegion in project FastAsyncWorldEdit by IntellectualSites.
the class ButcherBrush method build.
@Override
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
CylinderRegion region = CylinderRegion.createRadius(editSession, position, size);
List<? extends Entity> entities = editSession.getEntities(region);
Operations.completeLegacy(new EntityVisitor(entities.iterator(), flags.createFunction()));
}
Aggregations