From 6c75d6935e739a33ffb0ab947a6eb8f843fcde73 Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Sun, 1 Dec 2024 11:36:16 -0800 Subject: [PATCH] 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. --- .../moonrise/patches/collisions/CollisionUtil.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java b/src/main/java/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java index 18608d3..505ccd2 100644 --- a/src/main/java/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java +++ b/src/main/java/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java @@ -2162,10 +2162,16 @@ public final class CollisionUtil { 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();