Java Code Examples for com.sk89q.worldedit.math.transform.Transform#isIdentity()
The following examples show how to use
com.sk89q.worldedit.math.transform.Transform#isIdentity() .
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: RandomFullClipboardPattern.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
@Override public boolean apply(Extent extent, Vector setPosition, Vector getPosition) throws WorldEditException { ClipboardHolder holder = clipboards.get(PseudoRandom.random.random(clipboards.size())); AffineTransform transform = new AffineTransform(); if (randomRotate) { transform = transform.rotateY(PseudoRandom.random.random(4) * 90); holder.setTransform(new AffineTransform().rotateY(PseudoRandom.random.random(4) * 90)); } if (randomFlip) { transform = transform.scale(new Vector(1, 0, 0).multiply(-2).add(1, 1, 1)); } if (!transform.isIdentity()) { holder.setTransform(transform); } Clipboard clipboard = holder.getClipboard(); Schematic schematic = new Schematic(clipboard); Transform newTransform = holder.getTransform(); if (newTransform.isIdentity()) { schematic.paste(extent, setPosition, false); } else { schematic.paste(extent, worldData, setPosition, false, newTransform); } return true; }
Example 2
Source File: SchemGen.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
@Override public boolean spawn(PseudoRandom random, int x, int z) throws WorldEditException { mutable.mutX(x); mutable.mutZ(z); int y = extent.getNearestSurfaceTerrainBlock(x, z, mutable.getBlockY(), 0, 255); if (y == -1) return false; mutable.mutY(y); if (!mask.test(mutable)) { return false; } mutable.mutY(y + 1); ClipboardHolder holder = clipboards.get(PseudoRandom.random.random(clipboards.size())); if (randomRotate) { holder.setTransform(new AffineTransform().rotateY(PseudoRandom.random.random(4) * 90)); } Clipboard clipboard = holder.getClipboard(); Schematic schematic = new Schematic(clipboard); Transform transform = holder.getTransform(); if (transform.isIdentity()) { schematic.paste(extent, mutable, false); } else { schematic.paste(extent, worldData, mutable, false, transform); } mutable.mutY(y); return true; }
Example 3
Source File: WorldEditHelper.java From WorldEditSelectionVisualizer with MIT License | 4 votes |
public void updatePlayerVisualization(PlayerVisualizerInfos playerInfo, SelectionType type) { Player player = playerInfo.getPlayer(); LocalSession session; try { session = worldEditPlugin.getSession(player); } catch (Exception e) { // sometimes after a reload getSession create errors with WorldEdit, this prevent error spam return; } PlayerSelection playerSelection = playerInfo.getSelection(type).orElse(null); if (playerSelection == null || session == null) { return; } Vector3d origin = Vector3d.ZERO; Region region; if (type == SelectionType.CLIPBOARD) { ClipboardHolder clipboardHolder = getClipboardHolder(session); if (clipboardHolder == null) { playerSelection.resetSelection(); return; } Clipboard clipboard = clipboardHolder.getClipboard(); Transform transform = clipboardHolder.getTransform(); origin = plugin.getCompatibilityHelper().adaptClipboard(clipboard).getOrigin(); region = clipboard.getRegion().clone(); if (!transform.isIdentity()) { region = plugin.getCompatibilityHelper().adaptRegion(region).transform(transform, origin); } } else { region = getSelectedRegion(session); } if (region == null) { playerSelection.resetSelection(); return; } if (type == SelectionType.SELECTION && (region.getWorld() == null || !region.getWorld().getName().equals(player.getWorld().getName()))) { playerSelection.resetSelection(); return; } RegionAdapter regionAdapter = plugin.getCompatibilityHelper().adaptRegion(region); RegionInfos regionInfos = regionAdapter.getRegionsInfos(); if (regionInfos.equals(playerSelection.getLastSelectedRegion())) { SelectionPoints points = playerSelection.getSelectionPoints(); if (points == null || points.origin().equals(origin)) { return; } } if (!player.hasPermission("wesv.use")) { playerSelection.resetSelection(regionInfos); return; } GlobalSelectionConfig config = plugin.getSelectionConfig(type); if (region.getArea() > config.getMaxSelectionSize()) { if (!playerSelection.isLastSelectionTooLarge()) { String message = plugin.getMessage("selection-too-large").replace("%blocks%", Integer.toString(config.getMaxSelectionSize())); plugin.getCompatibilityHelper().sendActionBar(player, message); } playerSelection.resetSelection(regionInfos); playerSelection.setLastSelectionTooLarge(true); return; } plugin.updateHoldingSelectionItem(playerInfo); Bukkit.getPluginManager().callEvent(new SelectionChangeEvent(player, region)); ShapeProcessor<?> shapeProcessor = shapeProcessors.get(region.getClass()); if (shapeProcessor != null) { playerSelection.updateSelection(shapeProcessor.processSelection(regionAdapter, config, origin), regionInfos, config.getFadeDelay()); } else { // Unsupported selection type playerSelection.resetSelection(regionInfos); } }
Example 4
Source File: HeightMapMCAGenerator.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
public void addSchems(BufferedImage img, Mask mask, WorldData worldData, List<ClipboardHolder> clipboards, int rarity, int distance, boolean randomRotate) throws WorldEditException { if (img.getWidth() != getWidth() || img.getHeight() != getLength()) throw new IllegalArgumentException("Input image dimensions do not match the current height map!"); double doubleRarity = rarity / 100d; int index = 0; AffineTransform identity = new AffineTransform(); LocalBlockVector2DSet placed = new LocalBlockVector2DSet(); for (int z = 0; z < getLength(); z++) { mutable.mutZ(z); for (int x = 0; x < getWidth(); x++, index++) { int y = heights.getByte(index) & 0xFF; int height = img.getRGB(x, z) & 0xFF; if (height == 0 || PseudoRandom.random.nextInt(256) > height * doubleRarity) { continue; } mutable.mutX(x); mutable.mutY(y); if (!mask.test(mutable)) { continue; } if (placed.containsRadius(x, z, distance)) { continue; } placed.add(x, z); ClipboardHolder holder = clipboards.get(PseudoRandom.random.random(clipboards.size())); if (randomRotate) { int rotate = PseudoRandom.random.random(4) * 90; if (rotate != 0) { holder.setTransform(new AffineTransform().rotateY(PseudoRandom.random.random(4) * 90)); } else { holder.setTransform(identity); } } Clipboard clipboard = holder.getClipboard(); Schematic schematic = new Schematic(clipboard); Transform transform = holder.getTransform(); if (transform.isIdentity()) { schematic.paste(this, mutable, false); } else { schematic.paste(this, worldData, mutable, false, transform); } if (x + distance < getWidth()) { x += distance; index += distance; } else { break; } } } }
Example 5
Source File: HeightMapMCAGenerator.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
public void addSchems(Mask mask, WorldData worldData, List<ClipboardHolder> clipboards, int rarity, int distance, boolean randomRotate) throws WorldEditException { int scaledRarity = (256 * rarity) / 100; int index = 0; AffineTransform identity = new AffineTransform(); LocalBlockVector2DSet placed = new LocalBlockVector2DSet(); for (int z = 0; z < getLength(); z++) { mutable.mutZ(z); for (int x = 0; x < getWidth(); x++, index++) { int y = heights.getByte(index) & 0xFF; if (PseudoRandom.random.nextInt(256) > scaledRarity) { continue; } mutable.mutX(x); mutable.mutY(y); if (!mask.test(mutable)) { continue; } if (placed.containsRadius(x, z, distance)) { continue; } mutable.mutY(y + 1); placed.add(x, z); ClipboardHolder holder = clipboards.get(PseudoRandom.random.random(clipboards.size())); if (randomRotate) { int rotate = PseudoRandom.random.random(4) * 90; if (rotate != 0) { holder.setTransform(new AffineTransform().rotateY(PseudoRandom.random.random(4) * 90)); } else { holder.setTransform(identity); } } Clipboard clipboard = holder.getClipboard(); Schematic schematic = new Schematic(clipboard); Transform transform = holder.getTransform(); if (transform.isIdentity()) { schematic.paste(this, mutable, false); } else { schematic.paste(this, worldData, mutable, false, transform); } if (x + distance < getWidth()) { x += distance; index += distance; } else { break; } } } }