3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-14 20:10:05 +01:00
Paper/patches/server/0749-Add-EntityToggleSitEvent.patch

101 Zeilen
5.3 KiB
Diff

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
2024-10-25 20:09:45 +02:00
index 749ae54ee42229cb32ec5280bc59a88f74fde197..f6a253e063f4a2cf78a036e44431806a0ba270d9 100644
--- a/src/main/java/net/minecraft/world/entity/TamableAnimal.java
+++ b/src/main/java/net/minecraft/world/entity/TamableAnimal.java
2024-10-23 23:35:21 +02:00
@@ -87,7 +87,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
2024-10-23 23:35:21 +02:00
@@ -167,6 +167,12 @@ public abstract class TamableAnimal extends Animal implements OwnableEntity {
}
public void setInSittingPose(boolean inSittingPose) {
2024-06-14 03:30:23 +02:00
+ // 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;
2024-06-14 03:30:23 +02:00
+ // 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
2024-10-25 13:52:04 +02:00
index 67ea374ae3c66af434b4aadbe702a44d230fbe09..a9a8ebb2cebe668628d5bdb33fa1399e0ab1e08b 100644
--- a/src/main/java/net/minecraft/world/entity/animal/Fox.java
+++ b/src/main/java/net/minecraft/world/entity/animal/Fox.java
2024-10-23 23:35:21 +02:00
@@ -419,7 +419,7 @@ public class Fox extends Animal implements VariantHolder<Fox.Variant> {
this.setSleeping(nbt.getBoolean("Sleeping"));
2024-10-23 23:35:21 +02:00
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"));
2023-06-08 10:47:19 +02:00
if (this.level() instanceof ServerLevel) {
this.setTargetGoals();
2024-10-23 23:35:21 +02:00
@@ -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
2024-10-23 23:35:21 +02:00
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
2024-10-23 23:35:21 +02:00
@@ -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);
}
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-10-23 23:35:21 +02:00
index b6baa40dac6d6bf40c4ee7ee75b8a8e6f60733a1..c99d37a40c63726c11980adccc67d09fd5132885 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-10-23 23:35:21 +02:00
@@ -572,7 +572,7 @@ public class Camel extends AbstractHorse {
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 - 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);
this.gameEvent(GameEvent.ENTITY_ACTION);
2024-10-23 23:35:21 +02:00
@@ -581,7 +581,7 @@ public class Camel extends AbstractHorse {
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 - 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);
this.gameEvent(GameEvent.ENTITY_ACTION);
2024-10-23 23:35:21 +02:00
@@ -590,6 +590,7 @@ public class Camel extends AbstractHorse {
2023-03-15 15:37:41 +01:00
}
2023-06-08 10:47:19 +02:00
public void standUpInstantly() {
+ 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);
this.gameEvent(GameEvent.ENTITY_ACTION);
2023-06-08 10:47:19 +02:00
this.resetLastPoseChangeTickToFullStand(this.level().getGameTime());