Search in sources :

Example 1 with CylinderRegion

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);
    }
}
Also used : Random(java.util.Random) CylinderRegion(com.sk89q.worldedit.regions.CylinderRegion) AbstractRegion(com.sk89q.worldedit.regions.AbstractRegion)

Example 2 with CylinderRegion

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);
}
Also used : CuboidRegionSelector(com.sk89q.worldedit.regions.selector.CuboidRegionSelector) CylinderRegionSelector(com.sk89q.worldedit.regions.selector.CylinderRegionSelector) Polygonal2DRegionSelector(com.sk89q.worldedit.regions.selector.Polygonal2DRegionSelector) ConvexPolyhedralRegionSelector(com.sk89q.worldedit.regions.selector.ConvexPolyhedralRegionSelector) RegionSelector(com.sk89q.worldedit.regions.RegionSelector) ConvexPolyhedralRegionSelector(com.sk89q.worldedit.regions.selector.ConvexPolyhedralRegionSelector) Polygonal2DRegion(com.sk89q.worldedit.regions.Polygonal2DRegion) Polygonal2DRegionSelector(com.sk89q.worldedit.regions.selector.Polygonal2DRegionSelector) ConvexPolyhedralRegion(com.sk89q.worldedit.regions.ConvexPolyhedralRegion) CylinderRegion(com.sk89q.worldedit.regions.CylinderRegion) CylinderRegionSelector(com.sk89q.worldedit.regions.selector.CylinderRegionSelector) CuboidRegionSelector(com.sk89q.worldedit.regions.selector.CuboidRegionSelector)

Example 3 with CylinderRegion

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;
}
Also used : CylinderRegion(com.sk89q.worldedit.regions.CylinderRegion) ArrayList(java.util.ArrayList) LocalSession(com.sk89q.worldedit.LocalSession) EntityVisitor(com.sk89q.worldedit.function.visitor.EntityVisitor) EditSession(com.sk89q.worldedit.EditSession) BlockVector3(com.sk89q.worldedit.math.BlockVector3)

Example 4 with CylinderRegion

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;
}
Also used : CylinderRegion(com.sk89q.worldedit.regions.CylinderRegion) BlockVector3(com.sk89q.worldedit.math.BlockVector3) Logging(com.sk89q.worldedit.command.util.Logging) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 5 with CylinderRegion

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()));
}
Also used : CylinderRegion(com.sk89q.worldedit.regions.CylinderRegion) EntityVisitor(com.sk89q.worldedit.function.visitor.EntityVisitor)

Aggregations

CylinderRegion (com.sk89q.worldedit.regions.CylinderRegion)6 EntityVisitor (com.sk89q.worldedit.function.visitor.EntityVisitor)2 BlockVector3 (com.sk89q.worldedit.math.BlockVector3)2 EditSession (com.sk89q.worldedit.EditSession)1 LocalSession (com.sk89q.worldedit.LocalSession)1 CommandPermissions (com.sk89q.worldedit.command.util.CommandPermissions)1 Logging (com.sk89q.worldedit.command.util.Logging)1 AbstractRegion (com.sk89q.worldedit.regions.AbstractRegion)1 ConvexPolyhedralRegion (com.sk89q.worldedit.regions.ConvexPolyhedralRegion)1 Polygonal2DRegion (com.sk89q.worldedit.regions.Polygonal2DRegion)1 RegionSelector (com.sk89q.worldedit.regions.RegionSelector)1 ConvexPolyhedralRegionSelector (com.sk89q.worldedit.regions.selector.ConvexPolyhedralRegionSelector)1 CuboidRegionSelector (com.sk89q.worldedit.regions.selector.CuboidRegionSelector)1 CylinderRegionSelector (com.sk89q.worldedit.regions.selector.CylinderRegionSelector)1 Polygonal2DRegionSelector (com.sk89q.worldedit.regions.selector.Polygonal2DRegionSelector)1 ArrayList (java.util.ArrayList)1 Random (java.util.Random)1 Command (org.enginehub.piston.annotation.Command)1