mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 07:20:24 +01:00
Fix non-null initialisation of context collision shape
Force LazyEntityCollisionContext#getEntity() to delegate - By delegating when the entity is retrieved, we can correctly catch cases where the collision method is inspecting some entity state. Adjust constant collision shape determination - Our previous hack did not actually catch every case. For now, it will only assume a constant collision shape of EMPTY for air blocks. Fixes https://github.com/PaperMC/Paper/issues/11697
This commit is contained in:
parent
86e20be366
commit
6788ba5e80
1 changed files with 10 additions and 4 deletions
|
@ -18347,11 +18347,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+
|
||||
+ public CollisionContext getDelegate() {
|
||||
+ this.delegated = true;
|
||||
+ final Entity entity = this.getEntity();
|
||||
+ final Entity entity = super.getEntity();
|
||||
+ return this.delegate == null ? this.delegate = (entity == null ? CollisionContext.empty() : CollisionContext.of(entity)) : this.delegate;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Entity getEntity() {
|
||||
+ this.getDelegate();
|
||||
+ return super.getEntity();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isDescending() {
|
||||
+ return this.getDelegate().isDescending();
|
||||
+ }
|
||||
|
@ -31088,9 +31094,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ // Paper start - optimise collisions
|
||||
+ if (this.cache != null) {
|
||||
+ final VoxelShape collisionShape = this.cache.collisionShape;
|
||||
+ try {
|
||||
+ this.constantCollisionShape = this.getCollisionShape(null, null, null);
|
||||
+ } catch (final Throwable throwable) {
|
||||
+ if (this.isAir()) {
|
||||
+ this.constantCollisionShape = Shapes.empty();
|
||||
+ } else {
|
||||
+ this.constantCollisionShape = null;
|
||||
+ }
|
||||
+ this.occludesFullBlock = ((ca.spottedleaf.moonrise.patches.collisions.shape.CollisionVoxelShape)collisionShape).moonrise$occludesFullBlock();
|
||||
|
|
Loading…
Reference in a new issue