CammiePone / Cammies-Combat-Tweaks

An overhaul to Minecraft's combat for both PvP and PvE
https://www.curseforge.com/minecraft/mc-mods/cammies-combat-tweaks
Other
6 stars 0 forks source link

Shield bug cause player to be insta-killed #7

Closed domanhthang2110 closed 3 years ago

domanhthang2110 commented 3 years ago

When blocking with shield, especially with many mobs attacking you. Sometimes a mob will hit from the side and for whatever reason it insta-kill the player no matter the HP This is my shield config (I messed with it a bit to see if it fix the problem but it doesn't)


"shields": {
        "canParry": false,
        "parryWithinTicks": 5,
        "disableWeaponOnParryTicks": 100,
        "disableShieldOnParryTicks": 20,
        "maxShieldArc": 360.0,
        "minTicksHasToBeUp": 10,
        "disableShieldOnLetGoTicks": 0,
        "maxDamageBlocked": 100.0
    },
CammiePone commented 3 years ago

That is a horrific config, but I'll do a test in a bit to see if I can reproduce the bug and figure out what's wrong

domanhthang2110 commented 3 years ago

I just tested some more and it has something to do with the max damage blocked setting, when i set to 10 the bug cause me to take 10 dmg, and the config above is 100 so basically insta-kill This video is an example when setting that to 20 dmg

https://user-images.githubusercontent.com/24988535/138498642-defa75b1-4f99-4fd5-817b-7c86d37e1da1.mp4

domanhthang2110 commented 3 years ago

I think I fixed it XD, all I do is adding a check in the damage calculation part whether if the returned damage is >= 0 or not to prevent negative value. Not sure though, try doing it on your side


    @ModifyVariable(method = "damage", at = @At(value = "INVOKE",
            target = "Lnet/minecraft/entity/damage/DamageSource;isProjectile()Z"
    ), ordinal = 0)
    public float modifyShieldDamageProtection(float amount, DamageSource source) {
        if((damageAmount - CombatTweaks.getConfig().shields.maxDamageBlocked) < 0) 
            return 0;
        else 
            return damageAmount - CombatTweaks.getConfig().shields.maxDamageBlocked;
    }
CammiePone commented 3 years ago

Actually, that's partly the problem (same could be achieved like this):

    @ModifyVariable(method = "damage", at = @At(value = "INVOKE",
            target = "Lnet/minecraft/entity/damage/DamageSource;isProjectile()Z"
    ), ordinal = 0)
    public float modifyShieldDamageProtection(float amount, DamageSource source) {
        return Math.max(0, damageAmount - CombatTweaks.getConfig().shields.maxDamageBlocked);
    }

But there's another problem: the shield maxes out at a 180 degree arc because I'm dumb and bad at math, but I know how to fix it, so it'll be fixed sometime in the next release