Skip to content

Commit

Permalink
Fixed Elytra in 2 Block High Places
Browse files Browse the repository at this point in the history
Fixed Elytras when you spam jump in a 2 block high area.
  • Loading branch information
XDPXI committed Aug 23, 2024
1 parent 136cff7 commit b3b0dd4
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/client/java/com/ztrolix/zlibs/mixin/client/PlayerMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.ztrolix.zlibs.mixin.client;

import net.minecraft.entity.player.PlayerEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(PlayerEntity.class)
public class PlayerMixin {
@Inject(method = "checkFallFlying", at = @At("HEAD"), cancellable = true)
private void injectedStartFallFlying(CallbackInfoReturnable<Boolean> cir) {
if (((PlayerEntity) (Object) this).isSneaking()) return;
if (((PlayerEntity) (Object) this).isFallFlying()) return;
double offset = 4.0 / 16.0;
if (((PlayerEntity) (Object) this).isSprinting()) offset = 12.0 / 16.0;
if (this.doesCollideY(offset) && this.doesCollideY(-offset)) {
cir.setReturnValue(false);
}
}

@Unique
private boolean doesCollideY(double offsetY) {
return !((PlayerEntity) (Object) this).doesNotCollide(0, offsetY, 0);
}
}

0 comments on commit b3b0dd4

Please sign in to comment.