From a8a6d6df9d2adfc9ebb9882e3fcceab1aaae48a7 Mon Sep 17 00:00:00 2001 From: WeatheredCopperLantern <263057236+WeatheredCopperLantern@users.noreply.github.com> Date: Wed, 13 May 2026 07:52:31 +0200 Subject: [PATCH] Uses .pushEntityLocal in .checkInsideBlocks to make blocks work that check the entities position or bounding box in .entityInside. For example the EndPortal. Also replace the transformInverse translation to get the local bounds, this fixes being able to trigger .entityInside through corners. For example entering a Nether portal if standing where a corner block would be. --- .../entity/entities_in_blocks/EntityMixin.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/common/src/main/java/dev/ryanhcode/sable/mixin/entity/entities_in_blocks/EntityMixin.java b/common/src/main/java/dev/ryanhcode/sable/mixin/entity/entities_in_blocks/EntityMixin.java index 5a616845..aeb92b32 100644 --- a/common/src/main/java/dev/ryanhcode/sable/mixin/entity/entities_in_blocks/EntityMixin.java +++ b/common/src/main/java/dev/ryanhcode/sable/mixin/entity/entities_in_blocks/EntityMixin.java @@ -1,6 +1,7 @@ package dev.ryanhcode.sable.mixin.entity.entities_in_blocks; import dev.ryanhcode.sable.Sable; +import dev.ryanhcode.sable.api.SubLevelHelper; import dev.ryanhcode.sable.companion.math.BoundingBox3d; import dev.ryanhcode.sable.sublevel.SubLevel; import net.minecraft.CrashReport; @@ -36,12 +37,11 @@ public abstract class EntityMixin { protected void checkInsideBlocks(final CallbackInfo ci) { final AABB bounds = this.getBoundingBox(); - final BoundingBox3d localBounds = new BoundingBox3d(bounds); for (final SubLevel intersecting : Sable.HELPER.getAllIntersecting(this.level, new BoundingBox3d(bounds))) { - localBounds.set(bounds); - localBounds.transformInverse(intersecting.logicalPose(), localBounds); - final BlockPos minPos = BlockPos.containing(localBounds.minX + 1.0E-7, localBounds.minY + 1.0E-7, localBounds.minZ + 1.0E-7); - final BlockPos maxPos = BlockPos.containing(localBounds.maxX - 1.0E-7, localBounds.maxY - 1.0E-7, localBounds.maxZ - 1.0E-7); + SubLevelHelper.pushEntityLocal(intersecting, (Entity) (Object) this); + + final BlockPos minPos = BlockPos.containing(this.getBoundingBox().minX + 1.0E-7, this.getBoundingBox().minY + 1.0E-7, this.getBoundingBox().minZ + 1.0E-7); + final BlockPos maxPos = BlockPos.containing(this.getBoundingBox().maxX - 1.0E-7, this.getBoundingBox().maxY - 1.0E-7, this.getBoundingBox().maxZ - 1.0E-7); if (this.level.hasChunksAt(minPos, maxPos)) { final BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); @@ -50,6 +50,7 @@ protected void checkInsideBlocks(final CallbackInfo ci) { for (int j = minPos.getY(); j <= maxPos.getY(); j++) { for (int k = minPos.getZ(); k <= maxPos.getZ(); k++) { if (!this.isAlive()) { + SubLevelHelper.popEntityLocal(intersecting, (Entity) (Object) this); return; } @@ -60,6 +61,7 @@ protected void checkInsideBlocks(final CallbackInfo ci) { blockState.entityInside(this.level, mutableBlockPos, (Entity) (Object) this); this.onInsideBlock(blockState); } catch (final Throwable var12) { + SubLevelHelper.popEntityLocal(intersecting, (Entity) (Object) this); final CrashReport crashReport = CrashReport.forThrowable(var12, "Colliding entity with block"); final CrashReportCategory crashReportCategory = crashReport.addCategory("Block being collided with"); CrashReportCategory.populateBlockDetails(crashReportCategory, this.level, mutableBlockPos, blockState); @@ -69,6 +71,8 @@ protected void checkInsideBlocks(final CallbackInfo ci) { } } } + + SubLevelHelper.popEntityLocal(intersecting, (Entity) (Object) this); } } }