Skip to content

Commit

Permalink
add flight speed config option
Browse files Browse the repository at this point in the history
  • Loading branch information
Draylar committed May 24, 2021
1 parent ead3692 commit f96e91e
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/main/java/draylar/identity/cca/IdentityComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import net.minecraft.entity.passive.TameableEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.vehicle.BoatEntity;
import net.minecraft.item.AirBlockItem;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.network.ServerPlayerEntity;
Expand Down Expand Up @@ -86,8 +87,12 @@ public boolean setIdentity(LivingEntity identity) {
// update flight properties on player depending on identity
if (Identity.hasFlyingPermissions((ServerPlayerEntity) player)) {
Identity.ABILITY_SOURCE.grantTo(player, VanillaAbilities.ALLOW_FLYING);
player.abilities.flySpeed = Identity.CONFIG.flySpeed;
player.sendAbilitiesUpdate();
} else {
Identity.ABILITY_SOURCE.revokeFrom(player, VanillaAbilities.ALLOW_FLYING);
player.abilities.flySpeed = 0.05f;
player.sendAbilitiesUpdate();
}

// If the player is riding a Ravager and changes into an Identity that cannot ride Ravagers, kick them off.
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/draylar/identity/config/IdentityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ public class IdentityConfig implements Config {
@Comment(value = "If true, /identity commands will send feedback in the action bar.")
public boolean logCommands = true;

public float flySpeed = 0.05f;

@Override
public String getName() {
return "identity";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public class PlayerAdvancementTrackerMixin {
private void refreshFlight(Advancement advancement, String criterionName, CallbackInfoReturnable<Boolean> cir) {
if(Identity.hasFlyingPermissions(owner)) {
Identity.ABILITY_SOURCE.grantTo(owner, VanillaAbilities.ALLOW_FLYING);
owner.abilities.flySpeed = Identity.CONFIG.flySpeed;
owner.sendAbilitiesUpdate();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ 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);
((ServerPlayerEntity) (Object) this).abilities.flySpeed = Identity.CONFIG.flySpeed;
((ServerPlayerEntity) (Object) this).sendAbilitiesUpdate();
}

Identity.ABILITY_SOURCE.grantTo((ServerPlayerEntity) (Object) this, VanillaAbilities.FLYING);
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/identity.accesswidener
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ accessible field net/minecraft/client/render/entity/model/OcelotEntityModel righ
accessible field net/minecraft/client/render/entity/model/SpiderEntityModel rightFrontLeg Lnet/minecraft/client/model/ModelPart;
accessible field net/minecraft/client/render/entity/model/IllagerEntityModel rightAttackingArm Lnet/minecraft/client/model/ModelPart;
accessible field net/minecraft/client/render/entity/model/RavagerEntityModel rightFrontLeg Lnet/minecraft/client/model/ModelPart;
accessible field net/minecraft/client/render/entity/model/SquidEntityModel tentacles [Lnet/minecraft/client/model/ModelPart;
accessible field net/minecraft/client/render/entity/model/SquidEntityModel tentacles [Lnet/minecraft/client/model/ModelPart;

accessible field net/minecraft/entity/player/PlayerAbilities flySpeed F

0 comments on commit f96e91e

Please sign in to comment.