com.sk89q.worldedit.regions.CylinderRegion Java Examples
The following examples show how to use
com.sk89q.worldedit.regions.CylinderRegion.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CylinderSpawnpointGenerator.java From HeavySpleef with GNU General Public License v3.0 | 6 votes |
@Override public void generateSpawnpoints(CylinderRegion region, World world, List<Location> spawnpoints, int n) { Vector center = region.getCenter(); Vector2D radius = region.getRadius(); int radx = radius.getBlockX(); int radz = radius.getBlockZ(); int y = region.getMaximumY() + 1; for (int i = 0; i < n; i++) { double a = Math.random() * 2 * Math.PI; double randomradx = Math.random() * radx; double randomradz = Math.random() * radz; int rx = (int) (randomradx * Math.sin(a)); int rz = (int) (randomradz * Math.cos(a)); int px = center.getBlockX() + rx; int pz = center.getBlockZ() + rz; Location location = new Location(world, px, y, pz); spawnpoints.add(location); } }
Example #2
Source File: CylinderRegionXMLCodec.java From HeavySpleef with GNU General Public License v3.0 | 6 votes |
@Override public void apply(Element applyTo, CylinderRegion region) { Vector center = region.getCenter(); Vector2D radius = region.getRadius(); int minY = region.getMinimumY(); int maxY = region.getMaximumY(); Element centerElement = applyTo.addElement("center"); centerElement.addElement("x").addText(String.valueOf(center.getBlockX())); centerElement.addElement("y").addText(String.valueOf(center.getBlockY())); centerElement.addElement("z").addText(String.valueOf(center.getBlockZ())); Element radiusElement = applyTo.addElement("radius"); radiusElement.addElement("x").addText(String.valueOf(radius.getBlockX())); radiusElement.addElement("z").addText(String.valueOf(radius.getBlockZ())); applyTo.addElement("minY").addText(String.valueOf(minY)); applyTo.addElement("maxY").addText(String.valueOf(maxY)); }
Example #3
Source File: CylinderRegionXMLCodec.java From HeavySpleef with GNU General Public License v3.0 | 6 votes |
@Override public CylinderRegion asRegion(Element container) { Element centerElement = container.element("center"); Element radiusElement = container.element("radius"); Element minYElement = container.element("minY"); Element maxYElement = container.element("maxY"); int cx = Integer.parseInt(centerElement.elementText("x")); int cy = Integer.parseInt(centerElement.elementText("y")); int cz = Integer.parseInt(centerElement.elementText("z")); int rx = Integer.parseInt(radiusElement.elementText("x")); int rz = Integer.parseInt(radiusElement.elementText("z")); int minY = Integer.parseInt(minYElement.getText()); int maxY = Integer.parseInt(maxYElement.getText()); Vector center = new Vector(cx, cy, cz); Vector2D radius = new Vector2D(rx, rz); return new CylinderRegion(center, radius, minY, maxY); }
Example #4
Source File: CylinderRegionSchematicCodec.java From HeavySpleef with GNU General Public License v3.0 | 6 votes |
@Override public void apply(Map<String, Tag> tags, CylinderRegion region) { Vector center = region.getCenter(); Vector2D radius = region.getRadius(); int minY = region.getMinimumY(); int maxY = region.getMaximumY(); List<IntTag> centerList = Lists.newArrayList(); centerList.add(new IntTag(center.getBlockX())); centerList.add(new IntTag(center.getBlockY())); centerList.add(new IntTag(center.getBlockZ())); ListTag centerTag = new ListTag(IntTag.class, centerList); List<IntTag> radiusList = Lists.newArrayList(); radiusList.add(new IntTag(radius.getBlockX())); radiusList.add(new IntTag(radius.getBlockZ())); ListTag radiusTag = new ListTag(IntTag.class, radiusList); tags.put("center", centerTag); tags.put("radius", radiusTag); tags.put("minY", new IntTag(minY)); tags.put("maxY", new IntTag(maxY)); }
Example #5
Source File: CylinderRegionSchematicCodec.java From HeavySpleef with GNU General Public License v3.0 | 6 votes |
@Override public CylinderRegion asRegion(Map<String, Tag> tags) { ListTag centerTag = (ListTag) tags.get("center"); ListTag radiusTag = (ListTag) tags.get("radius"); int centerX = centerTag.getInt(0); int centerY = centerTag.getInt(1); int centerZ = centerTag.getInt(2); int pos2X = radiusTag.getInt(0); int pos2Z = radiusTag.getInt(1); Vector center = new Vector(centerX, centerY, centerZ); Vector2D radius = new Vector2D(pos2X, pos2Z); int minY = (int) tags.get("minY").getValue(); int maxY = (int) tags.get("maxY").getValue(); return new CylinderRegion(center, radius, minY, maxY); }
Example #6
Source File: WorldEditHelper.java From WorldEditSelectionVisualizer with MIT License | 5 votes |
private void registerShapeProcessors() { shapeProcessors.put(CuboidRegion.class, new CuboidProcessor(plugin)); shapeProcessors.put(Polygonal2DRegion.class, new Polygonal2DProcessor(plugin)); shapeProcessors.put(EllipsoidRegion.class, new EllipsoidProcessor(plugin)); shapeProcessors.put(CylinderRegion.class, new CylinderProcessor(plugin)); shapeProcessors.put(ConvexPolyhedralRegion.class, new ConvexPolyhedralProcessor(plugin)); if (plugin.getCompatibilityHelper().isUsingFawe()) { shapeProcessors.put(FawePolyhedralProcessor.getRegionClass(), new FawePolyhedralProcessor(plugin)); } }
Example #7
Source File: CylinderProcessor.java From WorldEditSelectionVisualizer with MIT License | 5 votes |
@Override protected void processSelection(SelectionPoints selection, CylinderRegion region, RegionAdapter regionAdapter, GlobalSelectionConfig config) { Vector3d min = regionAdapter.getMinimumPoint(); Vector3d max = regionAdapter.getMaximumPoint().add(1, 1, 1); Vector3d bottomCenter = regionAdapter.getCenter().withY(min.getY()).add(0.5, 0.0, 0.5); Vector3d topCenter = bottomCenter.withY(max.getY()); Vector3d radius = new Vector3d(region.getWidth() / 2.0, 0, region.getLength() / 2.0); createEllipse(selection.primary(), bottomCenter, radius, config.primary().getPointsDistance()); createEllipse(selection.primary(), topCenter, radius, config.primary().getPointsDistance()); double increment = DOUBLE_PI / 8; for (int i = 0; i < 8; i++) { double angle = i * increment; double x = bottomCenter.getX() + (radius.getX() * Math.cos(angle)); double z = bottomCenter.getZ() + (radius.getZ() * Math.sin(angle)); Vector3d bottom = new Vector3d(x, bottomCenter.getY(), z); Vector3d top = bottom.withY(topCenter.getY()); Collection<Vector3d> vectors = (i % 2 == 0) ? selection.primary() : selection.secondary(); double distance = ((i % 2 == 0) ? config.primary() : config.secondary()).getPointsDistance(); createLine(vectors, bottom, top, distance); createLine(vectors, bottom, bottomCenter, distance); createLine(vectors, top, topCenter, distance); } }
Example #8
Source File: CylinderRegionSelector.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
/** * Create a new selector from the given one. * * @param oldSelector the old selector */ public CylinderRegionSelector(RegionSelector oldSelector) { this(checkNotNull(oldSelector).getIncompleteRegion().getWorld()); if (oldSelector instanceof CylinderRegionSelector) { final CylinderRegionSelector cylSelector = (CylinderRegionSelector) oldSelector; region = new CylinderRegion(cylSelector.region); } else { final Region oldRegion; try { oldRegion = oldSelector.getRegion(); } catch (IncompleteRegionException e) { return; } Vector pos1 = oldRegion.getMinimumPoint(); Vector pos2 = oldRegion.getMaximumPoint(); Vector center = pos1.add(pos2).divide(2).floor(); region.setCenter(center.toVector2D()); region.setRadius(pos2.toVector2D().subtract(center.toVector2D())); region.setMaximumY(Math.max(pos1.getBlockY(), pos2.getBlockY())); region.setMinimumY(Math.min(pos1.getBlockY(), pos2.getBlockY())); } }
Example #9
Source File: CylinderRegionSelector.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public CylinderRegion getRegion() throws IncompleteRegionException { if (!isDefined()) { throw new IncompleteRegionException(); } return region; }
Example #10
Source File: CommandInfo.java From HeavySpleef with GNU General Public License v3.0 | 5 votes |
private String getRegionTypeName(Region region) { String regionType = null; if (region instanceof CuboidRegion) { regionType = i18n.getString(Messages.Command.CUBOID); } else if (region instanceof CylinderRegion) { regionType = i18n.getString(Messages.Command.CYLINDRICAL); } else if (region instanceof Polygonal2DRegion) { regionType = i18n.getString(Messages.Command.POLYGONAL); } return regionType; }
Example #11
Source File: CylinderProcessor.java From WorldEditSelectionVisualizer with MIT License | 4 votes |
public CylinderProcessor(WorldEditSelectionVisualizer plugin) { super(CylinderRegion.class, plugin); }
Example #12
Source File: CylinderRegionSelector.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
public CylinderRegionSelector(CylinderRegion region) { checkNotNull(region); this.region = region; }
Example #13
Source File: CylinderRegionSelector.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
@Override public CylinderRegion getIncompleteRegion() { return region; }
Example #14
Source File: CylinderRegionSelector.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
@Override public void clear() { region = new CylinderRegion(region.getWorld()); }
Example #15
Source File: CylinderRegionSelector.java From FastAsyncWorldedit with GNU General Public License v3.0 | 2 votes |
/** * Create a new region selector. * * @param world the world, which may be {@code null} */ public CylinderRegionSelector(@Nullable World world) { region = new CylinderRegion(world); }