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
2024-01-16 12:41:40 +01:00
Subject: [PATCH] Add EntityToggleSitEvent
2022-10-23 00:20:52 +02:00
diff --git a/src/main/java/net/minecraft/world/entity/TamableAnimal.java b/src/main/java/net/minecraft/world/entity/TamableAnimal.java
2024-06-14 03:30:23 +02:00
index 07ec4837d17a9cb7db2fa310a42fc87e052b3f9b..39adc89b35213d5d5fb71bb4b7e0c641f77e4a06 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
2024-06-14 03:30:23 +02:00
@@ -86,7 +86,7 @@ public abstract class TamableAnimal extends Animal implements OwnableEntity {
2022-10-23 04:55:28 +02:00
}
this.orderedToSit = nbt.getBoolean("Sitting");
- this.setInSittingPose(this.orderedToSit);
2024-01-16 12:41:40 +01:00
+ this.setInSittingPose(this.orderedToSit, false); // Paper - Add EntityToggleSitEvent
2022-10-23 04:55:28 +02:00
}
@Override
2024-06-14 03:30:23 +02:00
@@ -162,6 +162,12 @@ public abstract class TamableAnimal extends Animal implements OwnableEntity {
2022-10-23 00:20:52 +02:00
}
public void setInSittingPose(boolean inSittingPose) {
2024-06-14 03:30:23 +02:00
+ // Paper start - Add EntityToggleSitEvent
2022-10-23 04:55:28 +02:00
+ this.setInSittingPose(inSittingPose, true);
+ }
+ public void setInSittingPose(boolean inSittingPose, boolean callEvent) {
2024-01-16 12:41:40 +01:00
+ if (callEvent && !new io.papermc.paper.event.entity.EntityToggleSitEvent(this.getBukkitEntity(), inSittingPose).callEvent()) return;
2024-06-14 03:30:23 +02:00
+ // Paper end - Add EntityToggleSitEvent
byte b0 = (Byte) this.entityData.get(TamableAnimal.DATA_FLAGS_ID);
2022-10-23 00:20:52 +02:00
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
2024-06-14 03:30:23 +02:00
index 3265b3b5aede517b6fd8bb836947795bf8881350..9a0adf65d4d54852301a91b6fe444e4c5a139f5d 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
2024-04-24 23:23:56 +02:00
@@ -432,7 +432,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"));
2024-01-16 12:41:40 +01:00
+ this.setSitting(nbt.getBoolean("Sitting"), false); // Paper - Add EntityToggleSitEvent
2022-10-23 04:55:28 +02:00
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();
2024-04-24 23:23:56 +02:00
@@ -445,6 +445,12 @@ public class Fox extends Animal implements VariantHolder<Fox.Type> {
2022-10-23 00:20:52 +02:00
}
public void setSitting(boolean sitting) {
2024-01-16 19:27:39 +01:00
+ // Paper start - Add EntityToggleSitEvent
2022-10-23 04:55:28 +02:00
+ 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;
2024-01-16 19:27:39 +01:00
+ // Paper end - Add EntityToggleSitEvent
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
2024-06-14 03:30:23 +02:00
index 7b3d5322611990406028e59b1409907291e27b21..293d6891948e99ac9bd741008f7dcbc5fc1a2e3d 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
2024-06-14 03:30:23 +02:00
@@ -145,6 +145,7 @@ public class Panda extends Animal {
2022-10-23 00:20:52 +02:00
}
public void sit(boolean sitting) {
2024-01-16 12:41:40 +01:00
+ if (!new io.papermc.paper.event.entity.EntityToggleSitEvent(this.getBukkitEntity(), sitting).callEvent()) return; // Paper - Add EntityToggleSitEvent
2022-10-23 00:20:52 +02:00
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
2024-06-14 03:30:23 +02:00
index bdc845b36b316069a626dad6cf31f5bcc5cd7d35..71c1bc87ab5942fa07f187fa44089c08b5804e91 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
2024-06-14 03:30:23 +02:00
@@ -567,7 +567,7 @@ public class Camel extends AbstractHorse implements PlayerRideableJumping, Saddl
2023-03-15 15:37:41 +01:00
}
public void sitDown() {
- if (!this.isCamelSitting()) {
2024-01-16 12:41:40 +01:00
+ if (!this.isCamelSitting() && new io.papermc.paper.event.entity.EntityToggleSitEvent(this.getBukkitEntity(), true).callEvent()) { // Paper - Add EntityToggleSitEvent
2024-04-24 23:23:56 +02:00
this.makeSound(SoundEvents.CAMEL_SIT);
2023-03-15 15:37:41 +01:00
this.setPose(Pose.SITTING);
2023-09-22 17:51:48 +02:00
this.gameEvent(GameEvent.ENTITY_ACTION);
2024-06-14 03:30:23 +02:00
@@ -576,7 +576,7 @@ public class Camel extends AbstractHorse implements PlayerRideableJumping, Saddl
2023-03-15 15:37:41 +01:00
}
public void standUp() {
- if (this.isCamelSitting()) {
2024-01-16 12:41:40 +01:00
+ if (this.isCamelSitting() && new io.papermc.paper.event.entity.EntityToggleSitEvent(this.getBukkitEntity(), false).callEvent()) { // Paper - Add EntityToggleSitEvent
2024-04-24 23:23:56 +02:00
this.makeSound(SoundEvents.CAMEL_STAND);
2023-03-15 15:37:41 +01:00
this.setPose(Pose.STANDING);
2023-09-22 17:51:48 +02:00
this.gameEvent(GameEvent.ENTITY_ACTION);
2024-06-14 03:30:23 +02:00
@@ -585,6 +585,7 @@ public class Camel extends AbstractHorse implements PlayerRideableJumping, Saddl
2023-03-15 15:37:41 +01:00
}
2023-06-08 10:47:19 +02:00
public void standUpInstantly() {
2024-01-16 12:41:40 +01:00
+ if (this.isCamelSitting() && !new io.papermc.paper.event.entity.EntityToggleSitEvent(this.getBukkitEntity(), false).callEvent()) return; // Paper - Add EntityToggleSitEvent
2023-03-15 15:37:41 +01:00
this.setPose(Pose.STANDING);
2023-09-22 17:51:48 +02:00
this.gameEvent(GameEvent.ENTITY_ACTION);
2023-06-08 10:47:19 +02:00
this.resetLastPoseChangeTickToFullStand(this.level().getGameTime());