Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Damage Event Weapon Inconsistency #11329

Open
Lukadcf opened this issue Aug 25, 2024 · 0 comments
Open

Damage Event Weapon Inconsistency #11329

Lukadcf opened this issue Aug 25, 2024 · 0 comments
Labels
status: needs triage type: bug Something doesn't work as it was intended to. version: 1.20.4 Game version 1.20.4

Comments

@Lukadcf
Copy link

Lukadcf commented Aug 25, 2024

Expected behavior

I expect that when a Player triggers EntityDamageEvent & EntityDamageByEntityEvent through a melee attack that player.getEquipment().getItemInMainHand() or player.getInventory().getItemInMainHand() will return the weapon used to damage the entity.

Observed/Actual behavior

When attacking immediately after switching slots the new slot will be the mainhand, while the entity was hit with item in the previous slot. This behaviour can be verified by comparing the damage values with the weapon type in the video below.

With some practise this can be easily abused by switching to a slow weapon that triggers an ability within this event. Basically ignoring the slower attackspeed and still triggering the ability.

Steps/models to reproduce

DamageEventWeapon.1.-.Trim.mp4

Plugin and Datapack List

image
image

Paper version

This server is running Paper version git-Paper-497 (MC: 1.20.4) (Implementing API version 1.20.4-R0.1-SNAPSHOT) (Git: d8d54d9 on ver/1.20.4)
You are running the latest version

Other

Listeners used in the video:

@EventHandler(priority = EventPriority.LOWEST)
    public void onEntityDamage(EntityDamageByEntityEvent event) {
        if (!(event.getDamager() instanceof Player player)) return;
        player.sendMessage(Utils.colorize("&cWeapon: "+player.getEquipment().getItemInMainHand().getType()+" Damage: "+event.getDamage()));
    }

//Tested seperately

 @EventHandler(priority = EventPriority.LOWEST)
    public void onEntityDamage(EntityDamageEvent event) {
        if (!(event.getDamageSource().getCausingEntity() instanceof Player player)) return;
        player.sendMessage(Utils.colorize("&cWeapon: " + player.getInventory().getItemInMainHand().getType() + " Damage: " + event.getDamage()));
    }
@Lukadcf Lukadcf added status: needs triage type: bug Something doesn't work as it was intended to. labels Aug 25, 2024
@papermc-sniffer papermc-sniffer bot added the version: 1.20.4 Game version 1.20.4 label Aug 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs triage type: bug Something doesn't work as it was intended to. version: 1.20.4 Game version 1.20.4
Projects
Status: 🕑 Needs Triage
Development

No branches or pull requests

1 participant