[SPIGOT-7480] Add a PlayerRemoveEntitiesOnShoulderEvent Created: 13/Sep/23 Updated: 25/Dec/24 |
|
Status: | Open |
Project: | Spigot |
Component/s: | None |
Affects Version/s: | None |
Fix Version/s: | None |
Type: | New Feature | Priority: | Minor |
Reporter: | Kami Rori | Assignee: | Unassigned |
Resolution: | Unresolved | Votes: | 0 |
Labels: | None |
Version: | 1.20.1-R0.1-SNAPSHOT |
Guidelines Read: | Yes |
Description |
When a player who has parrot on his/her shoulders jumps or gets damaged, the entities (which are always parrots, but it doesnt matter) will be removed from his/her shoulders. That will trigger //代码占位符 protected void removeEntitiesOnShoulder() { if (this.timeEntitySatOnShoulder + 20L < this.level().getGameTime()) { // CraftBukkit start if (this.respawnEntityOnShoulder(this.getShoulderEntityLeft())) { this.setShoulderEntityLeft(new NBTTagCompound()); } if (this.respawnEntityOnShoulder(this.getShoulderEntityRight())) { this.setShoulderEntityRight(new NBTTagCompound()); } // CraftBukkit end } } But until now there hasnt been a good way to prevent this method being triggered. So its required to create an event for it. //代码占位符 protected void removeEntitiesOnShoulder() { PlayerRemoveEntitiesOnShoulderEvent event = new PlayerDropItemEvent(this, entityOnLeftShoulder, entityOnRightShoulder); this.level().getCraftServer().getPluginManager().callEvent(event); if (!event.isCancelled && this.timeEntitySatOnShoulder + 20L < this.level().getGameTime()) { // CraftBukkit start if (this.respawnEntityOnShoulder(this.getShoulderEntityLeft())) { this.setShoulderEntityLeft(new NBTTagCompound()); } if (this.respawnEntityOnShoulder(this.getShoulderEntityRight())) { this.setShoulderEntityRight(new NBTTagCompound()); } // CraftBukkit end } } This event requires: |