Jeryn99 / Gliders

Gliders: essential for traversing terrain and preventing falls
9 stars 3 forks source link

Glider often opens unintentionally (with code fix suggestion) #39

Closed Tim1Blau closed 1 year ago

Tim1Blau commented 1 year ago

When jumping, the glider often opens unintentionally. This can be very irritating, especially if the 3rd person switch is enabled.

This is because the glider opens when there is air below the player. But this check does not work as intended.

https://github.com/VentureCraftMods/MC-Gliders/assets/74421870/fd2bc21c-32d8-4054-b1a0-104c0cd6c81b

The problem is this, that this code checks the block below the player but the player might be standing on a different block

code:

in: common/src/main/java/net/venturecraft/gliders/util/GliderUtil.java

public static boolean canDeployHere(LivingEntity livingEntity) {
    boolean isAir = livingEntity.level.getBlockState(livingEntity.blockPosition().below(2)).isAir() && livingEntity.level.getBlockState(livingEntity.blockPosition().below()).isAir();
    boolean updraftAround = nearUpdraft(livingEntity);
    boolean isUpdraft = livingEntity.level.getBlockState(livingEntity.blockPosition().below()).is(VCGliderTags.UPDRAFT_BLOCKS);
    return isUpdraft || isAir || updraftAround || livingEntity.fallDistance > 2;
}

Fix Suggestion: Additional check if player is on ground

boolean isAir = !livingEntity.isOnGround() && livingEntity.level.getBlockState(livingEntity.blockPosition().below(2)).isAir() && livingEntity.level.getBlockState(livingEntity.blockPosition().below()).isAir();

Additional Fix for glider not closing when too close to the ground:

return isUpdraft || isAir || updraftAround || livingEntity.fallDistance > 2 || isGliderActive(livingEntity);

Hope you implement this fix :) Unfortunately i can't open a pull request for this myself.

Shibva commented 1 year ago

you can make a fork and them sent a merge request