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