From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: KyGuy2002 Date: Fri, 11 Mar 2022 15:33:10 +0000 Subject: [PATCH] Added EntityToggleSitEvent diff --git a/src/main/java/net/minecraft/world/entity/TamableAnimal.java b/src/main/java/net/minecraft/world/entity/TamableAnimal.java index acc25fb309568864dd7b53ad6a7a3ee6ff18e82a..49f52baa02db18af6d8626754423ff157eb9c09c 100644 --- a/src/main/java/net/minecraft/world/entity/TamableAnimal.java +++ b/src/main/java/net/minecraft/world/entity/TamableAnimal.java @@ -67,7 +67,7 @@ public abstract class TamableAnimal extends Animal implements OwnableEntity { } this.orderedToSit = nbt.getBoolean("Sitting"); - this.setInSittingPose(this.orderedToSit); + this.setInSittingPose(this.orderedToSit, false); // Paper - Don't fire event } @Override @@ -125,6 +125,12 @@ public abstract class TamableAnimal extends Animal implements OwnableEntity { } public void setInSittingPose(boolean inSittingPose) { + // Paper start + this.setInSittingPose(inSittingPose, true); + } + public void setInSittingPose(boolean inSittingPose, boolean callEvent) { + // Paper end + if (callEvent && !new io.papermc.paper.event.entity.EntityToggleSitEvent(this.getBukkitEntity(), inSittingPose).callEvent()) return; // Paper start - call EntityToggleSitEvent byte b = this.entityData.get(DATA_FLAGS_ID); if (inSittingPose) { this.entityData.set(DATA_FLAGS_ID, (byte)(b | 1)); diff --git a/src/main/java/net/minecraft/world/entity/animal/Fox.java b/src/main/java/net/minecraft/world/entity/animal/Fox.java index 6a66b5d1a3d8615dcc15057f03476e9ccbf4b4f2..06b11bdbccd76f166561bcaff444066cc46b4663 100644 --- a/src/main/java/net/minecraft/world/entity/animal/Fox.java +++ b/src/main/java/net/minecraft/world/entity/animal/Fox.java @@ -421,7 +421,7 @@ public class Fox extends Animal { this.setSleeping(nbt.getBoolean("Sleeping")); this.setFoxType(Fox.Type.byName(nbt.getString("Type"))); - this.setSitting(nbt.getBoolean("Sitting")); + this.setSitting(nbt.getBoolean("Sitting"), false); // Paper this.setIsCrouching(nbt.getBoolean("Crouching")); if (this.level instanceof ServerLevel) { this.setTargetGoals(); @@ -434,6 +434,12 @@ public class Fox extends Animal { } public void setSitting(boolean sitting) { + this.setSitting(sitting, true); + } + // Paper start + public void setSitting(boolean sitting, boolean fireEvent) { + if (fireEvent && !new io.papermc.paper.event.entity.EntityToggleSitEvent(this.getBukkitEntity(), sitting).callEvent()) return; + // Paper end this.setFlag(1, sitting); } diff --git a/src/main/java/net/minecraft/world/entity/animal/Panda.java b/src/main/java/net/minecraft/world/entity/animal/Panda.java index 39c26f486d6392eb0a9b623cdb2161846357174b..1494a3d5256f663b17617356d57d2e09aeec6189 100644 --- a/src/main/java/net/minecraft/world/entity/animal/Panda.java +++ b/src/main/java/net/minecraft/world/entity/animal/Panda.java @@ -131,6 +131,7 @@ public class Panda extends Animal { } public void sit(boolean sitting) { + if (!new io.papermc.paper.event.entity.EntityToggleSitEvent(this.getBukkitEntity(), sitting).callEvent()) return; // Paper start - call EntityToggleSitEvent this.setFlag(8, sitting); }