LogicUsing Events
Player Hit Entity
Triggers when a player damages a non-player entity.
This event fires when a player successfully damages any non-player entity (e.g., a Zombie, Cow, Armor Stand). This includes both melee and projectile attacks.
Action Values
Player: The player who dealt the damage.Entity: The entity that was damaged.Damage: A Number value representing the amount of damage dealt.
Event Configuration
- Target Entity Type: Filter the event to only trigger when a specific type of entity is hit (e.g., only
ZOMBIE). - Cancel Event: If
true, the damage will be cancelled, and the entity will not get hurt. - Execution Mode: Control how often the event can trigger (e.g.,
Once Per Entity).
Use Cases
- Creating a weapon that applies a special effect (like slow or poison) on hit.
- Making certain entities immune to player damage.
- Rewarding players for hitting a specific target in a minigame.
Example: A "Freezing Sword"
- Create Custom Item: Create a custom diamond sword named
&bSword of Frost. - Region: Select your main gameplay region.
- Event: Add a
Player Hit Entityevent. - Actions:
- Add a
Conditionalaction. - Condition:
Has Item-> check if thePlayeris holding theSword of Frost. - If Actions:
Potion Effect: Target theEntity, applySLOWNESSwith an amplifier of2for60ticks (3 seconds).
- Add a