Skip to content

Commit

Permalink
fix(spell being null due to delayed packets)
Browse files Browse the repository at this point in the history
  • Loading branch information
nvb-uy committed May 13, 2024
1 parent 1edaa79 commit 995c9ec
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
import org.spongepowered.asm.mixin.injection.ModifyVariable;

import com.bawnorton.mixinsquared.TargetHandler;
import com.llamalad7.mixinextras.sugar.Local;

import dev.kosmx.playerAnim.core.data.KeyframeAnimation;
import elocindev.deathknights.DeathKnights;
import elocindev.deathknights.config.Configs;
import net.bettercombat.BetterCombat;
import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.entity.attribute.EntityAttributes;
import net.minecraft.entity.player.PlayerEntity;
import net.spell_engine.client.animation.AnimationRegistry;
import net.spell_engine.internals.casting.SpellCasterEntity;

@Mixin(value = AbstractClientPlayerEntity.class, priority = 1500)
public class AnimationSpeedPatcherMixin {
Expand All @@ -22,34 +23,25 @@ public class AnimationSpeedPatcherMixin {
name = "playSpellAnimation"
)
@ModifyVariable(method = "@MixinSquared:Handler", at = @At("HEAD"), ordinal = 0)
private float death_knights$updateSpellCastAnimationsOnTick(float speed) {
PlayerEntity player = (PlayerEntity)(Object)this;

var spellCaster = ((SpellCasterEntity) player);
var spell = spellCaster.getCurrentSpell(); if (spell == null) return speed;

if (shouldPatchAnimation(spell.release.animation))
if (DeathKnights.BETTERCOMBAT_ENABLED) {
KeyframeAnimation animation = (KeyframeAnimation)AnimationRegistry.animations.get(spell.release.animation);

float syncedSpeed = (float) animation.endTick / (animation.getLength());
float upswingSpeed = syncedSpeed / BetterCombat.config.getUpswingMultiplier();

return upswingSpeed;
}
else
return 3f;
private float death_knights$playSpellAnimation(float speed, @Local String animation) {
AbstractClientPlayerEntity player = (AbstractClientPlayerEntity) (Object) this;

return speed;
}

public boolean shouldPatchAnimation(String animationid) {
for (String anim : Configs.Client.CONFIG.patched_animations) {
if (animationid.equals(anim)) {
return true;
if (animation != null && animation.equals(anim)) {
if (DeathKnights.BETTERCOMBAT_ENABLED && Configs.Client.CONFIG.enable_bettercombat_compatibility) {
KeyframeAnimation kfAnim = (KeyframeAnimation)AnimationRegistry.animations.get(animation);

float syncedSpeed = (float) kfAnim.endTick / (kfAnim.getLength());
float upswingSpeed = syncedSpeed / BetterCombat.config.getUpswingMultiplier();

float atkSpeed = (float) ((PlayerEntity) player).getAttributeValue(EntityAttributes.GENERIC_ATTACK_SPEED);

return upswingSpeed + atkSpeed;
}
else return 3f;
}
}

return false;
return speed;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
},
"cast": {
"duration": 0.0,
"sound": {
"id": "simplyswords:elemental_sword_ice_attack_03",
"randomness": 0
},
"particles": [
{
"particle_id": "spell_engine:frost_spell",
Expand All @@ -27,7 +23,8 @@
"type": "SELF"
},
"sound": {
"id": "simplyswords:elemental_sword_ice_attack_03"
"id": "spell_engine:generic_frost_release",
"pitch": 1.2
},
"particles": [
{
Expand Down
3 changes: 1 addition & 2 deletions src/main/resources/data/death_knights/spells/obliterate.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
"tier": 0
},
"cast": {
"duration": 0.0,
"animation": "spell_engine:one_handed_area_charge"
"duration": 0.0
},
"release": {
"target": {
Expand Down

0 comments on commit 995c9ec

Please sign in to comment.