Skip to content

Commit

Permalink
kick for self-attacking (#430)
Browse files Browse the repository at this point in the history
* 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`
  • Loading branch information
DataM0del authored Dec 29, 2024
1 parent 2d136b1 commit f4de9e4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pumpkin/src/net/packet/play.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down

0 comments on commit f4de9e4

Please sign in to comment.