|
32 | 32 | import com.sk89q.worldedit.extent.clipboard.Clipboard; |
33 | 33 | import com.sk89q.worldedit.function.block.BlockReplace; |
34 | 34 | import com.sk89q.worldedit.function.mask.Mask; |
| 35 | +import com.sk89q.worldedit.function.mask.Masks; |
35 | 36 | import com.sk89q.worldedit.function.operation.ForwardExtentCopy; |
36 | 37 | import com.sk89q.worldedit.function.operation.Operation; |
37 | 38 | import com.sk89q.worldedit.function.operation.Operations; |
@@ -308,18 +309,35 @@ void revolve(Actor actor, LocalSession session, EditSession editSession, @Select |
308 | 309 | // Offset this by half a block to ensure rotations are aligned properly |
309 | 310 | AffineTransform offsetTransform = new AffineTransform().translate(0.5, 0.5, 0.5); |
310 | 311 |
|
| 312 | + // Entities can't be offset like blocks, so we need a separate transform. Ideally can be fixed in WE8 by always |
| 313 | + // offsetting block stuff in ExtentBlockCopy so we don't need the above to be offset. |
| 314 | + AffineTransform entityTransform = copyEntities ? new AffineTransform() : null; |
| 315 | + |
311 | 316 | // Now paste it multiple times, rotating each time |
312 | 317 | for (int i = 1; i < pasteCount; i++) { |
313 | | - holder.setTransform(offsetTransform.rotateY((reverse ? 1 : -1) * (360 * i) / (double) pasteCount)); |
| 318 | + double theta = (reverse ? 1 : -1) * (360 * i) / (double) pasteCount; |
| 319 | + holder.setTransform(offsetTransform.rotateY(theta)); |
314 | 320 |
|
315 | 321 | Operation operation = holder |
316 | 322 | .createPaste(editSession) |
317 | 323 | .ignoreAirBlocks(true) |
318 | | - .copyEntities(copyEntities) |
| 324 | + .copyEntities(false) |
319 | 325 | .copyBiomes(copyBiomes) |
320 | 326 | .to(pasteOrigin) |
321 | 327 | .build(); |
322 | 328 | Operations.complete(operation); |
| 329 | + |
| 330 | + if (copyEntities) { |
| 331 | + // Paste entities separately with correct transform |
| 332 | + holder.setTransform(entityTransform.rotateY(theta)); |
| 333 | + Operation entityOperation = holder |
| 334 | + .createPaste(editSession) |
| 335 | + .maskSource(Masks.negate(Masks.alwaysTrue())) |
| 336 | + .copyEntities(true) |
| 337 | + .to(pasteOrigin) |
| 338 | + .build(); |
| 339 | + Operations.complete(entityOperation); |
| 340 | + } |
323 | 341 | } |
324 | 342 |
|
325 | 343 | actor.printInfo(TranslatableComponent.of("worldedit.revolve.revolved", TextComponent.of(pasteCount))); |
|
0 commit comments