aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOwen <[email protected]>2022-10-22 22:55:28 -0400
committerGitHub <[email protected]>2022-10-22 21:55:28 -0500
commit0b8f40cf6a1f7d86fe6c11f9f410e21e52691879 (patch)
treedab254fd6f98dc052b68b415a2cecd168e12ecd3
parent66650763422698310e1d0b73f75267d88092cea0 (diff)
downloadPaper-0b8f40cf6a1f7d86fe6c11f9f410e21e52691879.tar.gz
Paper-0b8f40cf6a1f7d86fe6c11f9f410e21e52691879.zip
Don't fire EntityToggleSitEvent on deserialization & reorder some api patches (#8495)
-rw-r--r--patches/api/0402-Add-EquipmentSlot-convenience-methods.patch (renamed from patches/api/0405-Add-EquipmentSlot-convenience-methods.patch)0
-rw-r--r--patches/api/0403-Add-LivingEntity-swingHand-EquipmentSlot-convenience.patch (renamed from patches/api/0402-Add-LivingEntity-swingHand-EquipmentSlot-convenience.patch)0
-rw-r--r--patches/api/0404-Add-entity-knockback-API.patch (renamed from patches/api/0403-Add-entity-knockback-API.patch)2
-rw-r--r--patches/api/0405-Added-EntityToggleSitEvent.patch (renamed from patches/api/0404-Added-EntityToggleSitEvent.patch)16
-rw-r--r--patches/server/0932-Added-EntityToggleSitEvent.patch40
5 files changed, 37 insertions, 21 deletions
diff --git a/patches/api/0405-Add-EquipmentSlot-convenience-methods.patch b/patches/api/0402-Add-EquipmentSlot-convenience-methods.patch
index 0ef6b4c9b0..0ef6b4c9b0 100644
--- a/patches/api/0405-Add-EquipmentSlot-convenience-methods.patch
+++ b/patches/api/0402-Add-EquipmentSlot-convenience-methods.patch
diff --git a/patches/api/0402-Add-LivingEntity-swingHand-EquipmentSlot-convenience.patch b/patches/api/0403-Add-LivingEntity-swingHand-EquipmentSlot-convenience.patch
index d4e19b6acd..d4e19b6acd 100644
--- a/patches/api/0402-Add-LivingEntity-swingHand-EquipmentSlot-convenience.patch
+++ b/patches/api/0403-Add-LivingEntity-swingHand-EquipmentSlot-convenience.patch
diff --git a/patches/api/0403-Add-entity-knockback-API.patch b/patches/api/0404-Add-entity-knockback-API.patch
index 402bff1723..a8167a1284 100644
--- a/patches/api/0403-Add-entity-knockback-API.patch
+++ b/patches/api/0404-Add-entity-knockback-API.patch
@@ -5,7 +5,7 @@ Subject: [PATCH] Add entity knockback API
diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
-index 319e4571aca24d1e3f6c85b7435d65c0e77a5245..c9a44e8024f903da83181ee752c971bab22c8895 100644
+index 435e214af7f09b3f1da078e6517cd14bb5ad2b87..3bd1d100d0c481ae7edaa251869640ab370aeb42 100644
--- a/src/main/java/org/bukkit/entity/LivingEntity.java
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java
@@ -1003,5 +1003,17 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
diff --git a/patches/api/0404-Added-EntityToggleSitEvent.patch b/patches/api/0405-Added-EntityToggleSitEvent.patch
index 01e55e8f9b..af2476123b 100644
--- a/patches/api/0404-Added-EntityToggleSitEvent.patch
+++ b/patches/api/0405-Added-EntityToggleSitEvent.patch
@@ -6,10 +6,10 @@ Subject: [PATCH] Added EntityToggleSitEvent
diff --git a/src/main/java/io/papermc/paper/event/entity/EntityToggleSitEvent.java b/src/main/java/io/papermc/paper/event/entity/EntityToggleSitEvent.java
new file mode 100644
-index 0000000000000000000000000000000000000000..982dad1bae89e52d29343101c424797e00a2b229
+index 0000000000000000000000000000000000000000..b53e9eb7df916721ad79925d711624b3da5619bb
--- /dev/null
+++ b/src/main/java/io/papermc/paper/event/entity/EntityToggleSitEvent.java
-@@ -0,0 +1,65 @@
+@@ -0,0 +1,53 @@
+package io.papermc.paper.event.entity;
+
+import org.bukkit.entity.Entity;
@@ -26,26 +26,14 @@ index 0000000000000000000000000000000000000000..982dad1bae89e52d29343101c424797e
+ private static final HandlerList HANDLER_LIST = new HandlerList();
+
+ private boolean cancelled;
-+ private final Entity entity;
+ private final boolean isSitting;
+
+ public EntityToggleSitEvent(@NotNull Entity entity, boolean isSitting) {
+ super(entity);
-+ this.entity = entity;
+ this.isSitting = isSitting;
+ }
+
+ /**
-+ * The entity involved.
-+ *
-+ * @return The entity.
-+ */
-+ @NotNull
-+ public Entity getEntity() {
-+ return this.entity;
-+ }
-+
-+ /**
+ * Gets the new sitting state that the entity will change to.
+ *
+ * @return If it's going to sit or not.
diff --git a/patches/server/0932-Added-EntityToggleSitEvent.patch b/patches/server/0932-Added-EntityToggleSitEvent.patch
index b663d99b58..72110ccbfb 100644
--- a/patches/server/0932-Added-EntityToggleSitEvent.patch
+++ b/patches/server/0932-Added-EntityToggleSitEvent.patch
@@ -5,26 +5,54 @@ 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..3d36b2198c07d1402f4b196d7c24682c6496ea48 100644
+index acc25fb309568864dd7b53ad6a7a3ee6ff18e82a..49f52baa02db18af6d8626754423ff157eb9c09c 100644
--- a/src/main/java/net/minecraft/world/entity/TamableAnimal.java
+++ b/src/main/java/net/minecraft/world/entity/TamableAnimal.java
-@@ -125,6 +125,7 @@ public abstract class TamableAnimal extends Animal implements OwnableEntity {
+@@ -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) {
-+ if (!new io.papermc.paper.event.entity.EntityToggleSitEvent(this.getBukkitEntity(), inSittingPose).callEvent()) return; // Paper start - call EntityToggleSitEvent
++ // 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..b1cb17d69bcbeca42136f97fcd136acde87f6568 100644
+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
-@@ -434,6 +434,7 @@ public class Fox extends Animal {
+@@ -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) {
-+ if (!new io.papermc.paper.event.entity.EntityToggleSitEvent(this.getBukkitEntity(), sitting).callEvent()) return; // Paper start - call EntityToggleSitEvent
++ 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);
}