aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0744-Add-EntityToggleSitEvent.patch
blob: 375c8635da2150f22163fcb7db45ab31b876ddd1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: KyGuy2002 <IEatBeans#1165>
Date: Fri, 11 Mar 2022 15:33:10 +0000
Subject: [PATCH] Add EntityToggleSitEvent


diff --git a/src/main/java/net/minecraft/world/entity/TamableAnimal.java b/src/main/java/net/minecraft/world/entity/TamableAnimal.java
index 1c195c928fb5c165981665393424a64004331c93..5bcdeb3eb463d637b16abfb43d5489c0334b6673 100644
--- a/src/main/java/net/minecraft/world/entity/TamableAnimal.java
+++ b/src/main/java/net/minecraft/world/entity/TamableAnimal.java
@@ -90,7 +90,7 @@ public abstract class TamableAnimal extends Animal implements OwnableEntity {
         }
 
         this.orderedToSit = nbt.getBoolean("Sitting");
-        this.setInSittingPose(this.orderedToSit);
+        this.setInSittingPose(this.orderedToSit, false); // Paper - Add EntityToggleSitEvent
     }
 
     @Override
@@ -174,6 +174,12 @@ public abstract class TamableAnimal extends Animal implements OwnableEntity {
     }
 
     public void setInSittingPose(boolean inSittingPose) {
+        // Paper start - Add EntityToggleSitEvent
+        this.setInSittingPose(inSittingPose, true);
+    }
+    public void setInSittingPose(boolean inSittingPose, boolean callEvent) {
+        if (callEvent && !new io.papermc.paper.event.entity.EntityToggleSitEvent(this.getBukkitEntity(), inSittingPose).callEvent()) return;
+        // Paper end - Add EntityToggleSitEvent
         byte b0 = (Byte) this.entityData.get(TamableAnimal.DATA_FLAGS_ID);
 
         if (inSittingPose) {
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 7d9d4df95b5abbe340f813a9cb765e59e2bd6fae..d48c2bdb004c86e9e08680138fe51dc3b2975a64 100644
--- a/src/main/java/net/minecraft/world/entity/animal/Fox.java
+++ b/src/main/java/net/minecraft/world/entity/animal/Fox.java
@@ -419,7 +419,7 @@ public class Fox extends Animal implements VariantHolder<Fox.Variant> {
 
         this.setSleeping(nbt.getBoolean("Sleeping"));
         this.setVariant(Fox.Variant.byName(nbt.getString("Type")));
-        this.setSitting(nbt.getBoolean("Sitting"));
+        this.setSitting(nbt.getBoolean("Sitting"), false); // Paper - Add EntityToggleSitEvent
         this.setIsCrouching(nbt.getBoolean("Crouching"));
         if (this.level() instanceof ServerLevel) {
             this.setTargetGoals();
@@ -432,6 +432,12 @@ public class Fox extends Animal implements VariantHolder<Fox.Variant> {
     }
 
     public void setSitting(boolean sitting) {
+        // Paper start - Add EntityToggleSitEvent
+        this.setSitting(sitting, true);
+    }
+    public void setSitting(boolean sitting, boolean fireEvent) {
+        if (fireEvent && !new io.papermc.paper.event.entity.EntityToggleSitEvent(this.getBukkitEntity(), sitting).callEvent()) return;
+        // Paper end - Add EntityToggleSitEvent
         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 4f04170b3ec4ff59358e10ccfd0799af3ab590c3..b654bec0fbe903fac24f3bb99399455bf367c68a 100644
--- a/src/main/java/net/minecraft/world/entity/animal/Panda.java
+++ b/src/main/java/net/minecraft/world/entity/animal/Panda.java
@@ -134,6 +134,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 - Add EntityToggleSitEvent
         this.setFlag(8, sitting);
     }
 
diff --git a/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java b/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java
index b6baa40dac6d6bf40c4ee7ee75b8a8e6f60733a1..c99d37a40c63726c11980adccc67d09fd5132885 100644
--- a/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java
+++ b/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java
@@ -572,7 +572,7 @@ public class Camel extends AbstractHorse {
     }
 
     public void sitDown() {
-        if (!this.isCamelSitting()) {
+        if (!this.isCamelSitting() && new io.papermc.paper.event.entity.EntityToggleSitEvent(this.getBukkitEntity(), true).callEvent()) { // Paper - Add EntityToggleSitEvent
             this.makeSound(SoundEvents.CAMEL_SIT);
             this.setPose(Pose.SITTING);
             this.gameEvent(GameEvent.ENTITY_ACTION);
@@ -581,7 +581,7 @@ public class Camel extends AbstractHorse {
     }
 
     public void standUp() {
-        if (this.isCamelSitting()) {
+        if (this.isCamelSitting() && new io.papermc.paper.event.entity.EntityToggleSitEvent(this.getBukkitEntity(), false).callEvent()) { // Paper - Add EntityToggleSitEvent
             this.makeSound(SoundEvents.CAMEL_STAND);
             this.setPose(Pose.STANDING);
             this.gameEvent(GameEvent.ENTITY_ACTION);
@@ -590,6 +590,7 @@ public class Camel extends AbstractHorse {
     }
 
     public void standUpInstantly() {
+        if (this.isCamelSitting() && !new io.papermc.paper.event.entity.EntityToggleSitEvent(this.getBukkitEntity(), false).callEvent()) return; // Paper - Add EntityToggleSitEvent
         this.setPose(Pose.STANDING);
         this.gameEvent(GameEvent.ENTITY_ACTION);
         this.resetLastPoseChangeTickToFullStand(this.level().getGameTime());