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-09-22 19:31:02 +02:00
|
|
|
index 188b4f2256058f9ebe96f3f2894dd30dc2e76b77..702efba07158330a8a747661673722223bc4d1e0 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-09-22 17:51:48 +02:00
|
|
|
index 9f24fb3ea75b9dcb41f70f6e4b0d6cd5dca57ff6..31d4683f5e158f076ce9a416b7003478af293688 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-09-22 17:51:48 +02:00
|
|
|
@@ -433,7 +433,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-09-22 17:51:48 +02:00
|
|
|
@@ -446,6 +446,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-09-22 17:51:48 +02:00
|
|
|
index 130761afcaa6723e0a9d9a518f1b526c344484b4..683cc5f9f066d554383fcd30e3654ac06ec76510 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
|
2023-09-22 17:51:48 +02:00
|
|
|
@@ -138,6 +138,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-09-22 19:31:02 +02:00
|
|
|
index 7407d7758f47273cfea8fdb8c8269a5fe74ebf17..5f83d8a950c5b90bc79f9274cdd4f3c332c1d3c2 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-09-22 17:51:48 +02:00
|
|
|
@@ -556,7 +556,7 @@ public class Camel extends AbstractHorse implements PlayerRideableJumping, Saddl
|
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
|
2023-09-22 17:51:48 +02:00
|
|
|
this.playSound(SoundEvents.CAMEL_SIT, 1.0F, this.getVoicePitch());
|
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);
|
|
|
|
@@ -565,7 +565,7 @@ public class Camel extends AbstractHorse implements PlayerRideableJumping, Saddl
|
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
|
2023-09-22 17:51:48 +02:00
|
|
|
this.playSound(SoundEvents.CAMEL_STAND, 1.0F, this.getVoicePitch());
|
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);
|
|
|
|
@@ -574,6 +574,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() {
|
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-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());
|