diff --git a/common/src/main/java/dev/ryanhcode/sable/mixin/player_standup/PlayerMixin.java b/common/src/main/java/dev/ryanhcode/sable/mixin/player_standup/PlayerMixin.java new file mode 100644 index 00000000..c92d306d --- /dev/null +++ b/common/src/main/java/dev/ryanhcode/sable/mixin/player_standup/PlayerMixin.java @@ -0,0 +1,33 @@ +package dev.ryanhcode.sable.mixin.player_standup; + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import dev.ryanhcode.sable.mixinhelpers.CanFallAtleastHelper; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.AABB; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +@Mixin(Player.class) +public class PlayerMixin { + + @WrapOperation( + method = "canPlayerFitWithinBlocksAndEntitiesWhen", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/level/Level;noCollision(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/phys/AABB;)Z" + ) + ) + private boolean sable$noCollisionWithSubLevels(final Level instance, final Entity entity, final AABB aabb, final Operation original) { + if (!original.call(instance, entity, aabb)) { + return false; + } + + // If vanilla says no collision, also check sublevel blocks. + // canFallAtleastWithSubLevels returns non-null when there IS a collision, + // meaning the player does NOT fit → return false. + return CanFallAtleastHelper.canFallAtleastWithSubLevels(instance, aabb) == null; + } +} diff --git a/common/src/main/resources/sable.mixins.json b/common/src/main/resources/sable.mixins.json index ad2263af..01cb74db 100644 --- a/common/src/main/resources/sable.mixins.json +++ b/common/src/main/resources/sable.mixins.json @@ -50,6 +50,7 @@ "particle.SuspendedParticleMixin", "particle.TerrainParticleMixin", "player_freezing.LocalPlayerMixin", + "player_standup.PlayerMixin", "plot.ClientChunkCacheMixin", "plot.MinecraftMixin", "plot.lighting.ClientPacketListenerMixin",