Paper icon indicating copy to clipboard operation
Paper copied to clipboard

Implemented EntityDamageDoorEvent

Open LB45440078L opened this issue 1 year ago • 4 comments

EntityDamageDoorEvent: Handle Door Damage Interactions

Description

I've introduced a new event called EntityDamageDoorEvent in the PaperMC server software. This event is triggered when an entity (currently limited to Zombies and Pillagers by default) damages a door. It provides essential information about the damaged door, the break time, and the total door break time.

This implementation takes into account differences in breaking time between zombies (240 ticks) and pillagers (60 ticks).

Event Details

  • Event Name: EntityDamageDoorEvent
  • Trigger: When an entity damages a door
  • Purpose: To allow developers to handle door damage interactions

Key Components

  1. Entity: The damaging entity (e.g., Zombie, Pillager).
  2. Door: The door being damaged.
  3. Break Time: The ticks spent breaking the door.
  4. Door Break Time: The total ticks required to break the door.

Usage Example

@EventHandler
public void onEntityDamageDoor(EntityDamageDoorEvent event) {
    Entity damagingEntity = event.getEntity();
    Door damagedDoor = event.getDamagedDoor();
    int breakTime = event.getBreakTime();
    int totalBreakTime = event.getDoorBreakTime();
    
    float percentage = ((float) breakTime / totalBreakTime) * 100f;
    if (percentage > 50.0f) {
        e.getNearbyEntities(5, 3, 5).stream()
            .filter(Player.class::isInstance)
            .map(Player.class::cast)
            .forEach(p -> p.sendMessage("Your home door is halfway broken, watch out dude :("));
    }
    // Additional logic...
}

LB45440078L avatar Mar 14 '24 16:03 LB45440078L

If you don't know what lynxplay is talking about: Read the contributing guidelines here: https://github.com/PaperMC/Paper/blob/master/CONTRIBUTING.md

Leguan16 avatar Mar 14 '24 20:03 Leguan16

yes I noticed I forgot to merge my patches :(

LB45440078L avatar Mar 14 '24 21:03 LB45440078L

Are you going to fix the patch situation or do you want me to do that?

lynxplay avatar Mar 16 '24 19:03 lynxplay

Are you going to fix the patch situation or do you want me to do that?

Yes please. I truly don't know how to do it. I tried merging my patches and it became even worse.

LB45440078L avatar Mar 17 '24 12:03 LB45440078L