Solved Damaging Players that are Hidden

Discussion in 'Plugin Development' started by DJCowGaming, May 24, 2020.

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

    DJCowGaming

    If I want to damage a player that is hidden with Player#hidePlayer, how should I do this? I'm using 1.15, and when a player is hidden it doesn't call the DamageByEntityEvent. Once I can get when the player has taken damage from an entity, how do I damage them? Damageable#damage doesn't seem to affect players.
     
  2. Offline

    KarimAKL

    @DJCowGaming What do you want to do? Sounds to me like you want players to be able to hit players they can't even see.
     
  3. Offline

    DJCowGaming

    I'm trying to add a disguise feature. What I am doing is hiding the player (with packets or with Player.hidePlayer, either one) and spawning a fake player where they are. I made some methods that make them look like the fake player is taking damage, moving, and changing hotbar slots, but I can't call the damage method if players can't be hit.
     
  4. Offline

    KarimAKL

    @DJCowGaming Try listening for the fake entity getting hit instead.
     
  5. Offline

    DJCowGaming

    I'm not really sure how to do that. The fake entity doesn't call the EntityDamageByEntityEvent, so I would have to use packet listeners, which I don't really know how to use.
     
  6. Offline

    KarimAKL

    @DJCowGaming I haven't worked with NMS for quite a while so, i'm not completely sure but, i guess you'd either have to listen for incoming packets, or add the entity to the world using MinecraftServer#addEntity(Entity, SpawnReason), although i'm not sure if the latter one does anything else.
     
  7. Offline

    DJCowGaming

    I figured it out with ProtocolLib, thanks for helping.
     
    KarimAKL likes this.
Thread Status:
Not open for further replies.

Share This Page