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-04-12 21:14:06 +02:00
index 01b91388577b6013d7bd5c9112a03f818fee1f9c..cf5cd0e49c4966e7b636a8ad4dec7a12806c6a4d 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-04-12 21:14:06 +02:00
@@ -69,7 +69,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
@@ -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) {
2024-01-16 12:41:40 +01: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;
+ // Paper end - Add 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
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
index 4c2e090a72dbd5bfb928e6ccbcedb1a25231d5b1..f7a7810fdc2f74b79fa14470493485e4b74539ab 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
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
@@ -437,7 +437,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();
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
@@ -450,6 +450,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
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
index 4abd26c7baf8f198f13dd41a3146f9ece13a4164..0297e234f17c6157cfff79420b9eeaf4e0e2c3ab 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
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
@@ -139,6 +139,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-03-09 00:52:00 +01:00
index 090d36d73b12fec59782142e2e85f17ba35dc6be..7860331b640fe48d1f2357d9f8e2e40c682b3620 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-03-09 00:52:00 +01:00
@@ -580,7 +580,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
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);
2024-03-09 00:52:00 +01:00
@@ -589,7 +589,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
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);
2024-03-09 00:52:00 +01:00
@@ -598,6 +598,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());