Skip to content

Commit 05ae91f

Browse files
Fix standing up from crawling (ryanhcode#929)
I'm going to deploy this fork to a private server for testing, but this fixed the issue in my initial testing for both: - when entering crawling via a trapdoor on the main level, then crawling under a sable sublevel - when entering crawling via a trapdoor while on a sable sublevel --------- Co-authored-by: Ocelot <FinntheRaider@gmail.com>
1 parent 37b4e16 commit 05ae91f

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package dev.ryanhcode.sable.mixin.player_standup;
2+
3+
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
4+
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
5+
import dev.ryanhcode.sable.mixinhelpers.CanFallAtleastHelper;
6+
import net.minecraft.world.entity.Entity;
7+
import net.minecraft.world.entity.player.Player;
8+
import net.minecraft.world.level.Level;
9+
import net.minecraft.world.phys.AABB;
10+
import org.spongepowered.asm.mixin.Mixin;
11+
import org.spongepowered.asm.mixin.injection.At;
12+
13+
@Mixin(Player.class)
14+
public class PlayerMixin {
15+
16+
@WrapOperation(
17+
method = "canPlayerFitWithinBlocksAndEntitiesWhen",
18+
at = @At(
19+
value = "INVOKE",
20+
target = "Lnet/minecraft/world/level/Level;noCollision(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/phys/AABB;)Z"
21+
)
22+
)
23+
private boolean sable$noCollisionWithSubLevels(final Level instance, final Entity entity, final AABB aabb, final Operation<Boolean> original) {
24+
if (!original.call(instance, entity, aabb)) {
25+
return false;
26+
}
27+
28+
// If vanilla says no collision, also check sublevel blocks.
29+
// canFallAtleastWithSubLevels returns non-null when there IS a collision,
30+
// meaning the player does NOT fit → return false.
31+
return CanFallAtleastHelper.canFallAtleastWithSubLevels(instance, aabb) == null;
32+
}
33+
}

common/src/main/resources/sable.mixins.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"particle.SuspendedParticleMixin",
5656
"particle.TerrainParticleMixin",
5757
"player_freezing.LocalPlayerMixin",
58+
"player_standup.PlayerMixin",
5859
"plot.ClientChunkCacheMixin",
5960
"plot.MinecraftMixin",
6061
"plot.lighting.ClientPacketListenerMixin",

0 commit comments

Comments
 (0)