[SPIGOT-6409] Add EntityFellOutOfWorldEvent Created: 04/Apr/21 Updated: 21/Feb/24 Resolved: 21/Feb/24 |
|
| Status: | Resolved |
| Project: | Spigot |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Minor |
| Reporter: | Ross | Assignee: | Unassigned |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Version: | n/a | ||||||||
| Guidelines Read: | Yes | ||||||||
| Description |
|
There is currently no event fired when an entity is removed from the game due to falling out of the world. The current way the community does this is by monitoring Y levels which is a painful solution - however with the min/max Y changes coming in 1.17 it would be a great time to add a new event for when entities fall out of the world (It'd be great to get this into 1.16 API too).
Please add a new event "EntityFellOutOfWorldEvent" and trigger it from net\minecraft\server\Entity.java public void entityBaseTick() { ... if (this.locY() < -64.0D) { // trigger EntityFellOutOfWorldEvent this.an(); }
|
| Comments |
| Comment by Martoph [ 02/May/21 ] |
|
This is managed in NonLivingEntityDamageEvent. @Override public boolean damageEntity(DamageSource damagesource, float f) { if (this.isInvulnerable(damagesource)) { return false; } else if (!this.getItemStack().isEmpty() && this.getItemStack().getItem() == Items.NETHER_STAR && damagesource.isExplosion()) { return false; } else if (!this.getItemStack().getItem().a(damagesource)) { return false; } else { // CraftBukkit start if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f)) { return false; } // CraftBukkit end this.velocityChanged(); this.f = (int) ((float) this.f - f); if (this.f <= 0) { this.die(); } return false; } } |
| Comment by Julian v.d Berkmortel [ 29/Apr/21 ] |
|
@md_5, what do you think of the idea of extending the "ItemDespawnEvent" to be called when an item is despawned because of the void? |
| Comment by Ross [ 18/Apr/21 ] |
|
@Julian that'd work for me too |
| Comment by Julian v.d Berkmortel [ 12/Apr/21 ] |
|
"ItemDespawnEvent" already exists, but is only called when an item despawns because of a 5 minute wait period. It could be extended without breaking backwards compatibility (in regards to the API at least) with a reason for despawning and call it when an entity gets despawned of the void as well. If an event like "EntityFellOutOfWorldEvent" were to be added I'd argue that a name more specific to items would be more suitable. It might be confusing when an entity is seen as "fell out of the world", when it actually despawns (which means for damageable entities when they die), immediately when it gets into the void or something else? |
| Comment by Ross [ 11/Apr/21 ] |
|
I'm trying to detect when items fall out of the world and no event fires when they fall out of the world and they don't take void damage on their way out - they just get "silently" removed. |
| Comment by md_5 [ 04/Apr/21 ] |
|
What are you trying to achieve? Why is DanageCause.VOID insufficient? |