-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add settings to rotate/mirror schematics #4452
Add settings to rotate/mirror schematics #4452
Conversation
|
||
@Override | ||
public BlockState desiredState(int x, int y, int z, BlockState current, List<BlockState> approxPlaceable) { | ||
return mirror(schematic.desiredState( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this flips the schematic in memory each time you call desiredState, I feel as though this could get really laggy on large schematics. Can we instead mirror it once in the constructor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, because the underlying schematic might have changed since the last call. We can only do this for static schematics, which most of our schematics are not (at least not reliably), and even then we might end up wasting memory by copying a sparse schematic into a dense array.
Also I think baking things in the wrapper schematic itself is actually a bad idea in most cases, because it forces the result to be static while we actually want it to be static iff it wraps a static schematic. Baking should be done separately from constructing the transformed schematic (i.e. schematic = new BakedSchematic(schematic)
).
IIRC mirroring block states is fairly fast (cache lookup) so the potentially laggy part here is transforming up to 36 states from approxPlaceable
. Given that we know how BuilderProcess
uses desiredState
we could commit a caching crime here (reuse last transformed if last untransformed == new untransformed, assuming the input wasn't mutated).
|
||
@Override | ||
public BlockState desiredState(int x, int y, int z, BlockState current, List<BlockState> approxPlaceable) { | ||
return rotate(schematic.desiredState( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
Closes #3711