mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-27 23:10:16 +01:00
Don't fire EntityToggleSitEvent on deserialization & reorder some api patches (#8495)
This commit is contained in:
parent
6665076342
commit
0b8f40cf6a
5 changed files with 37 additions and 21 deletions
|
@ -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
|
|
@ -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.
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue