Java Code Examples for com.sk89q.worldedit.util.Location#getYaw()
The following examples show how to use
com.sk89q.worldedit.util.Location#getYaw() .
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: BukkitWorld.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
private static org.bukkit.Location adapt(org.bukkit.World world, Location location) { checkNotNull(world); checkNotNull(location); return new org.bukkit.Location( world, location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); }
Example 2
Source File: NukkitUtil.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
public static cn.nukkit.level.Location toLocation(Location location) { return new cn.nukkit.level.Location(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch(), toLevel((LocalWorld) location.getExtent())); }
Example 3
Source File: ScaleTransform.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
@Nullable @Override public Entity createEntity(Location location, BaseEntity entity) { Location newLoc = new Location(location.getExtent(), getPos(location.getBlockX(), location.getBlockY(), location.getBlockZ()), location.getYaw(), location.getPitch()); return super.createEntity(newLoc, entity); }
Example 4
Source File: CopyPastaBrush.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
@Override public void build(final EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException { FawePlayer fp = editSession.getPlayer(); ClipboardHolder clipboard = session.getExistingClipboard(); if (clipboard == null) { if (editSession.getExtent() instanceof VisualExtent) { return; } Mask mask = editSession.getMask(); if (mask == null) { mask = Masks.alwaysTrue(); } final ResizableClipboardBuilder builder = new ResizableClipboardBuilder(editSession.getWorld()); final int size2 = (int) (size * size); final int minY = position.getBlockY(); mask = new AbstractDelegateMask(mask) { @Override public boolean test(Vector vector) { if (super.test(vector) && vector.getBlockY() >= minY) { BaseBlock block = editSession.getLazyBlock(vector); if (block.getId() != 0) { builder.add(vector, EditSession.nullBlock, block); return true; } } return false; } }; // Add origin mask.test(position); RecursiveVisitor visitor = new RecursiveVisitor(mask, new NullRegionFunction(), (int) size, editSession); visitor.visit(position); Operations.completeBlindly(visitor); // Build the clipboard Clipboard newClipboard = builder.build(); newClipboard.setOrigin(position); ClipboardHolder holder = new ClipboardHolder(newClipboard, editSession.getWorld().getWorldData()); session.setClipboard(holder); int blocks = builder.size(); BBC.COMMAND_COPY.send(fp, blocks); return; } else { AffineTransform transform = null; if (randomRotate) { if (transform == null) transform = new AffineTransform(); int rotate = 90 * PseudoRandom.random.nextInt(4); transform = transform.rotateY(rotate); } if (autoRotate) { if (transform == null) transform = new AffineTransform(); Location loc = editSession.getPlayer().getPlayer().getLocation(); float yaw = loc.getYaw(); float pitch = loc.getPitch(); transform = transform.rotateY((-yaw) % 360); transform = transform.rotateX(pitch - 90); } if (transform != null && !transform.isIdentity()) { clipboard.setTransform(transform); } Clipboard faweClip = clipboard.getClipboard(); Region region = faweClip.getRegion(); Operation operation = clipboard .createPaste(editSession, editSession.getWorldData()) .to(position.add(0, 1, 0)) .ignoreAirBlocks(true) .build(); Operations.completeLegacy(operation); editSession.flushQueue(); } }
Example 5
Source File: StencilBrush.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
@Override public void build(EditSession editSession, Vector position, Pattern pattern, double sizeDouble) throws MaxChangedBlocksException { final int cx = position.getBlockX(); final int cy = position.getBlockY(); final int cz = position.getBlockZ(); int size = (int) sizeDouble; int size2 = (int) (sizeDouble * sizeDouble); int maxY = editSession.getMaxY(); int add; if (yscale < 0) { add = maxY; } else { add = 0; } double scale = (yscale / sizeDouble) * (maxY + 1); final HeightMap map = getHeightMap(); map.setSize(size); int cutoff = onlyWhite ? maxY : 0; final SolidBlockMask solid = new SolidBlockMask(editSession); final AdjacentAnyMask adjacent = new AdjacentAnyMask(Masks.negate(solid)); Player player = editSession.getPlayer().getPlayer(); Vector pos = player.getPosition(); Location loc = editSession.getPlayer().getPlayer().getLocation(); float yaw = loc.getYaw(); float pitch = loc.getPitch(); AffineTransform transform = new AffineTransform().rotateY((-yaw) % 360).rotateX(pitch - 90).inverse(); RecursiveVisitor visitor = new RecursiveVisitor(new Mask() { private final MutableBlockVector mutable = new MutableBlockVector(); @Override public boolean test(Vector vector) { if (solid.test(vector)) { int dx = vector.getBlockX() - cx; int dy = vector.getBlockY() - cy; int dz = vector.getBlockZ() - cz; Vector srcPos = transform.apply(mutable.setComponents(dx, dy, dz)); dx = srcPos.getBlockX(); dz = srcPos.getBlockZ(); int distance = dx * dx + dz * dz; if (distance > size2 || Math.abs(dx) > 256 || Math.abs(dz) > 256) return false; double raise = map.getHeight(dx, dz); int val = (int) Math.ceil(raise * scale) + add; if (val < cutoff) { return true; } if (val >= 255 || PseudoRandom.random.random(maxY) < val) { editSession.setBlock(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ(), pattern); } return true; } return false; } }, vector -> true, Integer.MAX_VALUE, editSession); visitor.setDirections(Arrays.asList(visitor.DIAGONAL_DIRECTIONS)); visitor.visit(position); Operations.completeBlindly(visitor); }