From f4de9e41c8600257909c7502240b83687d696d4d Mon Sep 17 00:00:00 2001 From: DataModel <183248792+DataM0del@users.noreply.github.com> Date: Sun, 29 Dec 2024 11:19:14 -0500 Subject: [PATCH] kick for self-attacking (#430) * fix(combat): kick for self-attacking * chore(combat): fix the duplication of the word client * chore(pumpkin/src/net/packet/play.rs#Player/handle_interact): remove useless parens * fix(combat): compare entity IDs, not actual objects * chore(pumpkin/src/net/packet/play): `cargo fmt` --- pumpkin/src/net/packet/play.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pumpkin/src/net/packet/play.rs b/pumpkin/src/net/packet/play.rs index baf90465..d47a7235 100644 --- a/pumpkin/src/net/packet/play.rs +++ b/pumpkin/src/net/packet/play.rs @@ -556,10 +556,16 @@ impl Player { return; }; if victim.living_entity.health.load() <= 0.0 { - // you can trigger this from a non-modded / innocent client client, + // you can trigger this from a non-modded / innocent client, // so we shouldn't kick the player return; } + if victim.entity_id() == self.entity_id() { + // this, however, can't be triggered from a non-modded client. + self.kick(TextComponent::text("You can't attack yourself")) + .await; + return; + } self.attack(&victim).await; } ActionType::Interact | ActionType::InteractAt => {