2022-10-23 00:20:52 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: KyGuy2002 <IEatBeans#1165>
|
|
|
|
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
|
2023-06-08 10:47:19 +02:00
|
|
|
index 9fb11df7131f400e6e631146c32efccea83adf56..1282911b97292cde30dff83de756bc91bf319cb2 100644
|
2022-10-23 00:20:52 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/TamableAnimal.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/TamableAnimal.java
|
2022-10-23 04:55:28 +02:00
|
|
|
@@ -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 {
|
2022-10-23 00:20:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setInSittingPose(boolean inSittingPose) {
|
2022-10-23 04:55:28 +02:00
|
|
|
+ // 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
|
2022-10-23 00:20:52 +02:00
|
|
|
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
|
2023-06-08 10:47:19 +02:00
|
|
|
index 167f142d6960867320b90d61db312ebf23e24a48..844083101e9763330af0175388f6cdda27a97ecc 100644
|
2022-10-23 00:20:52 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/animal/Fox.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/animal/Fox.java
|
2023-03-14 22:10:53 +01:00
|
|
|
@@ -427,7 +427,7 @@ public class Fox extends Animal implements VariantHolder<Fox.Type> {
|
2022-10-23 04:55:28 +02:00
|
|
|
|
|
|
|
this.setSleeping(nbt.getBoolean("Sleeping"));
|
2022-12-07 23:05:32 +01:00
|
|
|
this.setVariant(Fox.Type.byName(nbt.getString("Type")));
|
2022-10-23 04:55:28 +02:00
|
|
|
- this.setSitting(nbt.getBoolean("Sitting"));
|
|
|
|
+ this.setSitting(nbt.getBoolean("Sitting"), false); // Paper
|
|
|
|
this.setIsCrouching(nbt.getBoolean("Crouching"));
|
2023-06-08 10:47:19 +02:00
|
|
|
if (this.level() instanceof ServerLevel) {
|
2022-10-23 04:55:28 +02:00
|
|
|
this.setTargetGoals();
|
2023-03-14 22:10:53 +01:00
|
|
|
@@ -440,6 +440,12 @@ public class Fox extends Animal implements VariantHolder<Fox.Type> {
|
2022-10-23 00:20:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setSitting(boolean sitting) {
|
2022-10-23 04:55:28 +02:00
|
|
|
+ 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
|
2022-10-23 00:20:52 +02:00
|
|
|
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
|
2023-06-08 10:47:19 +02:00
|
|
|
index a0933b8467bf81333dc103055e73bb75069dcb36..9b807b318a2843810c3963277d464439a865cfb6 100644
|
2022-10-23 00:20:52 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/animal/Panda.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/animal/Panda.java
|
2022-12-07 23:05:32 +01:00
|
|
|
@@ -132,6 +132,7 @@ public class Panda extends Animal {
|
2022-10-23 00:20:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2023-03-15 15:37:41 +01:00
|
|
|
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
|
2023-06-08 10:47:19 +02:00
|
|
|
index 2030fdb3124f793d7b545135b1db32fe9be27050..4efa7e331cc974008c653a04687a336e97626445 100644
|
2023-03-15 15:37:41 +01:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java
|
2023-06-08 10:47:19 +02:00
|
|
|
@@ -591,7 +591,7 @@ public class Camel extends AbstractHorse implements PlayerRideableJumping, Rider
|
2023-03-15 15:37:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void sitDown() {
|
|
|
|
- if (!this.isCamelSitting()) {
|
|
|
|
+ if (!this.isCamelSitting() && new io.papermc.paper.event.entity.EntityToggleSitEvent(this.getBukkitEntity(), true).callEvent()) { // Paper
|
|
|
|
this.playSound(SoundEvents.CAMEL_SIT, 1.0F, 1.0F);
|
|
|
|
this.setPose(Pose.SITTING);
|
2023-06-08 10:47:19 +02:00
|
|
|
this.resetLastPoseChangeTick(-this.level().getGameTime());
|
|
|
|
@@ -599,7 +599,7 @@ public class Camel extends AbstractHorse implements PlayerRideableJumping, Rider
|
2023-03-15 15:37:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void standUp() {
|
|
|
|
- if (this.isCamelSitting()) {
|
|
|
|
+ if (this.isCamelSitting() && new io.papermc.paper.event.entity.EntityToggleSitEvent(this.getBukkitEntity(), false).callEvent()) { // Paper
|
|
|
|
this.playSound(SoundEvents.CAMEL_STAND, 1.0F, 1.0F);
|
|
|
|
this.setPose(Pose.STANDING);
|
2023-06-08 10:47:19 +02:00
|
|
|
this.resetLastPoseChangeTick(this.level().getGameTime());
|
|
|
|
@@ -607,6 +607,7 @@ public class Camel extends AbstractHorse implements PlayerRideableJumping, Rider
|
2023-03-15 15:37:41 +01:00
|
|
|
}
|
|
|
|
|
2023-06-08 10:47:19 +02:00
|
|
|
public void standUpInstantly() {
|
2023-03-15 15:37:41 +01:00
|
|
|
+ if (this.isCamelSitting() && !new io.papermc.paper.event.entity.EntityToggleSitEvent(this.getBukkitEntity(), false).callEvent()) return; // Paper
|
|
|
|
this.setPose(Pose.STANDING);
|
2023-06-08 10:47:19 +02:00
|
|
|
this.resetLastPoseChangeTickToFullStand(this.level().getGameTime());
|
2023-03-15 15:37:41 +01:00
|
|
|
}
|