From f96e91ea9f63140ed1adebd212d7f229cc266633 Mon Sep 17 00:00:00 2001 From: Draylar Date: Mon, 24 May 2021 14:20:09 -0500 Subject: [PATCH] add flight speed config option --- src/main/java/draylar/identity/cca/IdentityComponent.java | 5 +++++ src/main/java/draylar/identity/config/IdentityConfig.java | 2 ++ .../identity/mixin/PlayerAdvancementTrackerMixin.java | 2 ++ .../java/draylar/identity/mixin/ServerPlayerEntityMixin.java | 2 ++ src/main/resources/identity.accesswidener | 4 +++- 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/draylar/identity/cca/IdentityComponent.java b/src/main/java/draylar/identity/cca/IdentityComponent.java index 918b22f..f11ef59 100644 --- a/src/main/java/draylar/identity/cca/IdentityComponent.java +++ b/src/main/java/draylar/identity/cca/IdentityComponent.java @@ -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; @@ -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. diff --git a/src/main/java/draylar/identity/config/IdentityConfig.java b/src/main/java/draylar/identity/config/IdentityConfig.java index f194491..1b75b2a 100644 --- a/src/main/java/draylar/identity/config/IdentityConfig.java +++ b/src/main/java/draylar/identity/config/IdentityConfig.java @@ -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"; diff --git a/src/main/java/draylar/identity/mixin/PlayerAdvancementTrackerMixin.java b/src/main/java/draylar/identity/mixin/PlayerAdvancementTrackerMixin.java index e4e9edd..509970a 100644 --- a/src/main/java/draylar/identity/mixin/PlayerAdvancementTrackerMixin.java +++ b/src/main/java/draylar/identity/mixin/PlayerAdvancementTrackerMixin.java @@ -23,6 +23,8 @@ public class PlayerAdvancementTrackerMixin { private void refreshFlight(Advancement advancement, String criterionName, CallbackInfoReturnable cir) { if(Identity.hasFlyingPermissions(owner)) { Identity.ABILITY_SOURCE.grantTo(owner, VanillaAbilities.ALLOW_FLYING); + owner.abilities.flySpeed = Identity.CONFIG.flySpeed; + owner.sendAbilitiesUpdate(); } } } diff --git a/src/main/java/draylar/identity/mixin/ServerPlayerEntityMixin.java b/src/main/java/draylar/identity/mixin/ServerPlayerEntityMixin.java index 802543e..3ddfb93 100644 --- a/src/main/java/draylar/identity/mixin/ServerPlayerEntityMixin.java +++ b/src/main/java/draylar/identity/mixin/ServerPlayerEntityMixin.java @@ -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); diff --git a/src/main/resources/identity.accesswidener b/src/main/resources/identity.accesswidener index 6542e3e..8e8656b 100644 --- a/src/main/resources/identity.accesswidener +++ b/src/main/resources/identity.accesswidener @@ -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; \ No newline at end of file +accessible field net/minecraft/client/render/entity/model/SquidEntityModel tentacles [Lnet/minecraft/client/model/ModelPart; + +accessible field net/minecraft/entity/player/PlayerAbilities flySpeed F \ No newline at end of file