Interaction deadzone between 2.5 and 4.5 Blocks

Discussion in 'Plugin Development' started by B3cksgold, Dec 29, 2022.

Thread Status:
Not open for further replies.
  1. Offline

    B3cksgold

    Hey everyone,

    I recently stumbled across a problem, that i can't seem to find any information about.

    for context:
    I'm currently developing a lightweight RPG-Plugin for our private server. I'd like to code the custom weapons myself and found some strange behaviour while doing so.

    If you stand between ~2.5 to~4.5 blocks away from a Mob and perform a Left-Click to attack you get no event call for PlayerInteractEvent (Right Click works!)

    and also none for EntityDamageByEntityEvent.
    since EntityDamageByEntityEvent gets called if vanilla minecraft detects the hit or i do damage and call it myself i wouldn't have expected it to be called, just wanted to clear it up.
    i printed every call of those and in between the 2.5 to 4.5 block range nothing gets printed.

    For true ranged weapons and normal melee weapons that is no problem. but a sword with modified range does just nothing since i use those two events as triggers for damagemanipulation and hit-testing.
    Outside of this deadzone PlayerInteract gets called again and it works as intended.

    Does Anyone of you know if there is an Event getting called in between those ranges ?
    or what Event i could use to perform Raytrace-hittesting myself?

    I only found Papers PlayerArmSwingEvent, which gets called pretty often so would need to give it a proper cooldown. But before trying this i wanted to aks if anyone knows more about this deadzone.

    i don't know if code is necessary but feel free to ask if you think it could matter.



    Attached a video so you can see for yourself.

    Thanks for your time!

    best regards, B3cks


    I found the cause and a solution and wanted to share it with you in case someone has the same problem.

    it has to do with PaperServer 1.19.2

    the problem was indeed, that no PlayerInteractEvent got fired, because the Values to Trigger it are wrong.
    someone also noticed this and released a patch but it hasn't been merged yet.

    if someone is interested in building his own server .jar, you can find the code to fix it in this git commit:

    https://github.com/PaperMC/Paper/bl...erver/0942-Fix-rouge-armswing-detection.patch

    i hope linking this is okay.

    i cloned the repo, checked out 1.19.2 and followed the instructions on the PaperMC readme to build it and apply all patches. afterwards you can modify the code in
    "Paper-Server/src/main/java/net/server/network/ServerGamePacketListenerImpl.java"

    Code:
    Line 2754         double d3 = player.gameMode.getGameModeForPlayer() == GameType.CREATIVE ? 5.0D : 4.5D;
    
    to
    
    double d3 = player.gameMode.getGameModeForPlayer() == GameType.CREATIVE ? 5.0D : 3.0D;
    
    
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.

    ty, my bad
     
    Last edited: Dec 29, 2022
Thread Status:
Not open for further replies.

Share This Page