Skip to content

Commit

Permalink
fix flight being revoked after death, 1.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Draylar committed Jul 31, 2020
1 parent 79acf85 commit 5caea2c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ yarn_mappings=1.16.1+build.21
loader_version=0.9.0+build.204

# Mod Properties
mod_version=1.5.0
mod_version=1.5.1
maven_group=draylar
archives_base_name=identity

Expand Down
8 changes: 0 additions & 8 deletions src/main/java/draylar/identity/cca/IdentityComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,6 @@ else if (type.isPresent()) {

// refresh player dimensions/hitbox on client
((DimensionsRefresher) player).refresh();

// refresh flight abilities
// TODO remove when compatibility with old saves is no longer needed
if(!player.world.isClient) {
if (Identity.hasFlyingPermissions((ServerPlayerEntity) player)) {
Identity.ABILITY_SOURCE.grantTo(player, VanillaAbilities.ALLOW_FLYING);
}
}
}

identity.fromTag(entityTag);
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/draylar/identity/mixin/ServerPlayerEntityMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import draylar.identity.Identity;
import draylar.identity.registry.Components;
import io.github.ladysnake.pal.VanillaAbilities;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.damage.DamageSource;
Expand Down Expand Up @@ -50,4 +51,18 @@ private void revokeIdentityOnDeath(DamageSource source, CallbackInfo ci) {
}
}
}

@Inject(
method = "onSpawn",
at = @At("HEAD")
)
private void onSpawn(CallbackInfo ci) {
if(Identity.hasFlyingPermissions((ServerPlayerEntity) (Object) this)) {
if(!Identity.ABILITY_SOURCE.grants((ServerPlayerEntity) (Object) this, VanillaAbilities.ALLOW_FLYING)) {
Identity.ABILITY_SOURCE.grantTo((ServerPlayerEntity) (Object) this, VanillaAbilities.ALLOW_FLYING);
}

Identity.ABILITY_SOURCE.grantTo((ServerPlayerEntity) (Object) this, VanillaAbilities.FLYING);
}
}
}

0 comments on commit 5caea2c

Please sign in to comment.