kernitus / BukkitOldCombatMechanics

Spigot plugin to configure combat mechanics from 1.9 onwards
https://www.spigotmc.org/resources/19510/
Mozilla Public License 2.0
168 stars 71 forks source link

Sword Block 1.8 ViaVersion inaccurate #441

Closed MeFisto94 closed 2 years ago

MeFisto94 commented 4 years ago

Information

Problem Description

Sword Blocking with ViaVersion depends on the client version. We've disabled the shield functionality from via-version.

When joining with a 1.8 client, incoming damage is possible (it logs EntityDamageByEntityListener). When joining with an 1.15.2 client, incoming damage is completely absorbed by the armor. When not wearing armor, I get the damage which is exactly 50% of the incoming damage (ShieldDamageReduction applied, but the EntityDamageByEntityListener does not print).

What I guess happens is that for the 1.8 client, the armor is reducing the damage before the shield reduction is applied or anything.

To Reproduce

Steps to reproduce the behavior: Try to hit eachother with 1.8.8 and 1.15.2 while being sword blocked.

Hitting an 1.8 player from 1.15.2: grafik

Hitting an 1.15.2 player from 1.8: grafik

Expected Behaviour

Actual Behaviour

See Problem Description

Sorry for the bad problem description, we try to dig into it ourselves as well.

EDIT: Debugging showed a lot: The incoming EntityDamageEvent has a different final damage. For the 1.15.2 player, the following modificators are present:

modifier = BASE double = 14.25
modifier = BLOCKING double = -14.25
modifier = ARMOR double = -0.0
modifier = RESISTANCE double = -0.0
modifier = MAGIC double = -0.0
modifier = ABSORPTION double = -0.0

For the 1.8.8 player, the following modificators are present:

modifier = BASE double = 14.25
modifier = BLOCKING double = -0.0
modifier = ARMOR double = -9.369375228881836
modifier = RESISTANCE double = -0.0
modifier = MAGIC double = -3.1235997676849365
modifier = ABSORPTION double = -0.0

The problem is now I don't know which modifiers are those that OCM needs, I guess the 1.15.2 ones, but I also don't know if I can hijack the event with reflection.

Edit 2: So blocking is not set for the 1.8.8 player due to via version / our config / something. I need to find out why Armor and Magic are set, though and probably fix that the damage reduction in combination with the armor lead to invulnerability

rayzr522 commented 4 years ago

i'm a little unclear on what to look into here, since it seems you've done a large amount of investigation yourself. can you reproduce this with a minimum setup of just OCM + ViaVersion + your particular configs for the two? if so, could you please share both of those here?

kernitus commented 4 years ago

@MeFisto94 the values should be taken server-side, so this seems to be something to do with how ViaVersion is doing things. Also, this plugin was not built for 1.8 and so there is always the possibility of wacky stuff happening there.

MeFisto94 commented 4 years ago

So I guess this is reproducable with a default setup of OCM and ViaVersion (that being said ViaVersion needs ViaBackwards and ViaRewind for this to work): The catch is, we want to provide a 1.8 combat experience, where the users even use 1.8 clients (as opposed to more recent ones). We just want the latest API improvements, peformance and other advancements and thus we don't use an 1.8 server, but an 1.15 one.

So to reiterate:

Ideally I'd like to have the 1.8 client behavior also on 1.9+ clients, which means changing the SHIELD modifier somehow. The first priority however is how to get to those magic values/make all clients behave the same, I guess.

kernitus commented 4 years ago

OCM recalculates most damages applied to the players, because Bukkit does not provide sufficient APIs to do this kind of thing. So, when blocking with a shield, the damage is reduced as would have happened when sword-blocking in 1.8, and not entirely stopped, as in 1.9. If you find that not to be the case, then it may well be ViaVersion that is interfering.

Also, what exactly do ViaBackwards and ViaRewind do? Could they be the issue?