|
33 | 33 | import com.sk89q.worldedit.extent.Extent; |
34 | 34 | import com.sk89q.worldedit.extent.InputExtent; |
35 | 35 | import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; |
| 36 | +import com.sk89q.worldedit.extent.clipboard.Clipboard; |
36 | 37 | import com.sk89q.worldedit.function.GroundFunction; |
37 | 38 | import com.sk89q.worldedit.function.RegionFunction; |
38 | 39 | import com.sk89q.worldedit.function.RegionMaskingFilter; |
|
52 | 53 | import com.sk89q.worldedit.internal.expression.ExpressionException; |
53 | 54 | import com.sk89q.worldedit.internal.util.TransformUtil; |
54 | 55 | import com.sk89q.worldedit.math.BlockVector3; |
| 56 | +import com.sk89q.worldedit.math.Vector3; |
55 | 57 | import com.sk89q.worldedit.math.convolution.GaussianKernel; |
56 | 58 | import com.sk89q.worldedit.math.convolution.HeightMap; |
57 | 59 | import com.sk89q.worldedit.math.convolution.HeightMapFilter; |
@@ -502,13 +504,28 @@ public int deform(Actor actor, LocalSession session, EditSession editSession, |
502 | 504 | @Switch(name = 'o', desc = "Use the placement's coordinate origin") |
503 | 505 | boolean offsetPlacement, |
504 | 506 | @Switch(name = 'c', desc = "Use the selection's center as origin") |
505 | | - boolean offsetCenter) throws WorldEditException { |
| 507 | + boolean offsetCenter, |
| 508 | + @Switch(name = 'l', desc = "Fetch from the clipboard instead of the world") |
| 509 | + boolean useClipboard) throws WorldEditException { |
| 510 | + final Transform targetTransform = TransformUtil.createTransformForExpressionCommand(actor, session, region, useRawCoords, offsetPlacement, offsetCenter); |
506 | 511 |
|
507 | | - final Transform transform = TransformUtil.createTransformForExpressionCommand(actor, session, region, useRawCoords, offsetPlacement, offsetCenter); |
508 | | - final InputExtent inputExtent = editSession.getWorld(); |
| 512 | + final InputExtent sourceExtent; |
| 513 | + final Transform sourceTransform; |
| 514 | + if (useClipboard) { |
| 515 | + final Clipboard clipboard = session.getClipboard().getClipboard(); |
| 516 | + sourceExtent = clipboard; |
| 517 | + |
| 518 | + final Vector3 clipboardMin = clipboard.getMinimumPoint().toVector3(); |
| 519 | + final Vector3 clipboardMax = clipboard.getMaximumPoint().toVector3(); |
| 520 | + |
| 521 | + sourceTransform = TransformUtil.createTransformForExpressionCommand(useRawCoords, offsetPlacement, offsetCenter, clipboardMin, clipboardMax, clipboardMin); |
| 522 | + } else { |
| 523 | + sourceExtent = editSession.getWorld(); |
| 524 | + sourceTransform = targetTransform; |
| 525 | + } |
509 | 526 |
|
510 | 527 | try { |
511 | | - final int affected = editSession.deformRegion(region, transform, String.join(" ", expression), session.getTimeout(), inputExtent, transform); |
| 528 | + final int affected = editSession.deformRegion(region, targetTransform, String.join(" ", expression), session.getTimeout(), sourceExtent, sourceTransform); |
512 | 529 | if (actor instanceof Player) { |
513 | 530 | ((Player) actor).findFreePosition(); |
514 | 531 | } |
|
0 commit comments