Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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<Boolean> 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;
}
}
1 change: 1 addition & 0 deletions common/src/main/resources/sable.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"particle.SuspendedParticleMixin",
"particle.TerrainParticleMixin",
"player_freezing.LocalPlayerMixin",
"player_standup.PlayerMixin",
"plot.ClientChunkCacheMixin",
"plot.MinecraftMixin",
"plot.lighting.ClientPacketListenerMixin",
Expand Down