Skip to content

Commit a87a686

Browse files
committed
Replace redirect with wrap operation
1 parent 8011d0d commit a87a686

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,33 @@
11
package dev.ryanhcode.sable.mixin.player_standup;
22

3+
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
4+
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
35
import dev.ryanhcode.sable.mixinhelpers.CanFallAtleastHelper;
46
import net.minecraft.world.entity.Entity;
57
import net.minecraft.world.entity.player.Player;
68
import net.minecraft.world.level.Level;
79
import net.minecraft.world.phys.AABB;
810
import org.spongepowered.asm.mixin.Mixin;
911
import org.spongepowered.asm.mixin.injection.At;
10-
import org.spongepowered.asm.mixin.injection.Redirect;
1112

1213
@Mixin(Player.class)
1314
public class PlayerMixin {
1415

15-
@Redirect(
16+
@WrapOperation(
1617
method = "canPlayerFitWithinBlocksAndEntitiesWhen",
1718
at = @At(
1819
value = "INVOKE",
1920
target = "Lnet/minecraft/world/level/Level;noCollision(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/phys/AABB;)Z"
2021
)
2122
)
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+
}
2627

2728
// If vanilla says no collision, also check sublevel blocks.
2829
// canFallAtleastWithSubLevels returns non-null when there IS a collision,
2930
// meaning the player does NOT fit → return false.
30-
return CanFallAtleastHelper.canFallAtleastWithSubLevels(level, aabb) == null;
31+
return CanFallAtleastHelper.canFallAtleastWithSubLevels(instance, aabb) == null;
3132
}
3233
}

0 commit comments

Comments
 (0)