fix: correct lazycopy dimensions and world usage - #3520
Conversation
dordsor21
commented
May 10, 2026
- fixes //lazycopy dimensiona too large #3472
- fixes LAZYCOPY will not copy clipboard source world #3496
|
|
||
| @Override | ||
| public long getMaxSize() { | ||
| return -1; |
There was a problem hiding this comment.
Why not just use Long.MAX_VALUE? The specification of the method in the superclass should also cover which values are valid.
There was a problem hiding this comment.
I wanted to convey actually unlimited rather than functionally unlimited. It should go into the javadoc though yeah
| * | ||
| * @return maximum size in blocks of this clipboard implementation. | ||
| */ | ||
| public long getMaxSize() { |
There was a problem hiding this comment.
An instance method is somehow the wrong approach, mainly because it requires an escaping this in the constructor, and it also doesn't have any different use really. Maybe SimpleClipboard is generally a rather problematic abstraction?
There was a problem hiding this comment.
It is, but altering the hierarchy is rather a v3 change and it would be nice to have this working a little sooner than that... We could always deprecate for removal upon implementation and put the change into V3 immediately.
Alternatively I suppose we could just reimplement in a different class entirely? Certainly the clipboard hierarchy could do with some cleanup at some point regardless
There was a problem hiding this comment.
Pull request overview
This PR addresses two //lazycopy regressions by allowing WorldCopyClipboard to represent extremely large selections without hitting the SimpleClipboard size guard, and by reducing the chance that the clipboard’s backing extent is reused/reinitialized in a way that changes the source world.
Changes:
- Add configurable “max volume” constructors to
SimpleClipboard/ReadOnlyClipboardand use an “infinite” limit forWorldCopyClipboard. - Update
WorldCopyClipboardto construct its base clipboard with an unlimited max size and uncache the queue when aSingleThreadQueueExtentis detected. - Refactor deprecated
WorldCopyClipboardconstructors to delegate through the new constructor path.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/WorldCopyClipboard.java | Uses unlimited clipboard sizing for lazy copy and uncaches queue when a reusable single-thread queue extent is present. |
| worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/SimpleClipboard.java | Introduces max-size-aware constructors and changes the size guard to use that max. |
| worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/ReadOnlyClipboard.java | Exposes max-size-aware construction for read-only clipboards and defaults to the prior size limit behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| * New {@link SimpleClipboard} instance for the given region with max volume of {@link Integer#MAX_VALUE}. Initial offset | ||
| * is the clipboard minimum point. |
| this.area = getWidth() * getLength(); | ||
| this.volume = (int) longVolume; | ||
| this.origin = BlockVector3.ZERO; |
| * New {@link ReadOnlyClipboard} instance for the given region with max volume of {@link Integer#MAX_VALUE}. Initial offset | ||
| * is the clipboard minimum point. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Suppressed comments (1)
worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/SimpleClipboard.java:63
maxSize == -1currently allows volumes larger thanInteger.MAX_VALUE, butareaandvolumeare still stored asint(this.area = getWidth() * getLength();andthis.volume = (int) longVolume;). For very large regions this will overflow and can turn negative; additionally thelongmultiplication can overflow for large-but-valid Minecraft coordinate ranges (e.g. ~60M x 4096 x ~60M). Consider usingMath.multiplyExactto detect overflow andInts.saturatedCast(or equivalent) sogetArea()/getVolume()never return nonsensical negative values when large lazy clipboards are permitted.
if (maxSize != -1 && longVolume > maxSize) {
throw new IllegalArgumentException("Dimensions are too large for this clipboard format.");
}
this.area = getWidth() * getLength();
this.volume = (int) longVolume;