2021-06-11 14:02:28 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: BillyGalbreath <Blake.Galbreath@GMail.com>
Date: Fri, 27 Jul 2018 22:36:31 -0500
Subject: [PATCH] SkeletonHorse Additions
diff --git a/src/main/java/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java b/src/main/java/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java
2023-06-07 22:19:14 +02:00
index 8f20239f3ef7ebe41fac8ee6e024c36dafec33c4..d00fb16ae3b94dfcb10fd1a7c1671595e2ff1855 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java
+++ b/src/main/java/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java
2022-12-07 19:52:24 +01:00
@@ -18,6 +18,7 @@ import net.minecraft.world.item.enchantment.EnchantmentHelper;
2021-06-11 14:02:28 +02:00
public class SkeletonTrapGoal extends Goal {
private final SkeletonHorse horse;
2021-06-13 01:45:00 +02:00
+ private java.util.List<org.bukkit.entity.HumanEntity> eligiblePlayers; // Paper
2021-06-11 14:02:28 +02:00
public SkeletonTrapGoal(SkeletonHorse skeletonHorse) {
this.horse = skeletonHorse;
2022-12-07 19:52:24 +01:00
@@ -25,12 +26,13 @@ public class SkeletonTrapGoal extends Goal {
2021-06-11 14:02:28 +02:00
@Override
public boolean canUse() {
2023-06-07 22:19:14 +02:00
- return this.horse.level().hasNearbyAlivePlayerThatAffectsSpawning(this.horse.getX(), this.horse.getY(), this.horse.getZ(), 10.0D); // Paper - Affects Spawning API
+ return !(eligiblePlayers = this.horse.level().findNearbyBukkitPlayers(this.horse.getX(), this.horse.getY(), this.horse.getZ(), 10.0D, net.minecraft.world.entity.EntitySelector.PLAYER_AFFECTS_SPAWNING)).isEmpty(); // Paper - Affects Spawning API & SkeletonHorseTrapEvent
2021-06-11 14:02:28 +02:00
}
@Override
public void tick() {
2023-06-07 22:19:14 +02:00
ServerLevel worldserver = (ServerLevel) this.horse.level();
2021-06-11 14:02:28 +02:00
+ if (!new com.destroystokyo.paper.event.entity.SkeletonHorseTrapEvent((org.bukkit.entity.SkeletonHorse) this.horse.getBukkitEntity(), eligiblePlayers).callEvent()) return; // Paper
DifficultyInstance difficultydamagescaler = worldserver.getCurrentDifficultyAt(this.horse.blockPosition());
this.horse.setTrap(false);
diff --git a/src/main/java/net/minecraft/world/level/EntityGetter.java b/src/main/java/net/minecraft/world/level/EntityGetter.java
2024-01-24 13:07:40 +01:00
index 07e7851ca27ea0f8166be52b086a6504c0deea09..e7b6f97d8519a5797903664e5ba2a793e37a4bfc 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/level/EntityGetter.java
+++ b/src/main/java/net/minecraft/world/level/EntityGetter.java
2024-01-24 13:07:40 +01:00
@@ -93,6 +93,28 @@ public interface EntityGetter {
2021-06-13 01:45:00 +02:00
return player;
2021-06-11 14:02:28 +02:00
}
+ // Paper start
2021-06-13 01:45:00 +02:00
+ default List<org.bukkit.entity.HumanEntity> findNearbyBukkitPlayers(double x, double y, double z, double radius, boolean notSpectator) {
+ return findNearbyBukkitPlayers(x, y, z, radius, notSpectator ? EntitySelector.NO_SPECTATORS : net.minecraft.world.entity.EntitySelector.NO_CREATIVE_OR_SPECTATOR);
2021-06-11 14:02:28 +02:00
+ }
+
2021-06-13 01:45:00 +02:00
+ default List<org.bukkit.entity.HumanEntity> findNearbyBukkitPlayers(double x, double y, double z, double radius, @Nullable Predicate<Entity> predicate) {
+ com.google.common.collect.ImmutableList.Builder<org.bukkit.entity.HumanEntity> builder = com.google.common.collect.ImmutableList.builder();
2021-06-11 14:02:28 +02:00
+
+ for (Player human : this.players()) {
+ if (predicate == null || predicate.test(human)) {
2021-06-17 23:39:36 +02:00
+ double distanceSquared = human.distanceToSqr(x, y, z);
2021-06-11 14:02:28 +02:00
+
+ if (radius < 0.0D || distanceSquared < radius * radius) {
+ builder.add(human.getBukkitEntity());
+ }
+ }
+ }
+
+ return builder.build();
+ }
+ // Paper end
+
@Nullable
default Player getNearestPlayer(Entity entity, double maxDistance) {
return this.getNearestPlayer(entity.getX(), entity.getY(), entity.getZ(), maxDistance, false);
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeletonHorse.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeletonHorse.java
2023-12-05 18:20:55 +01:00
index 248e4febbe8fe225920b6504d2c29d295cf09ec6..fbb47491dcc75f8247dee9f123f946f99ef1467f 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeletonHorse.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeletonHorse.java
2023-08-14 01:32:51 +02:00
@@ -44,4 +44,16 @@ public class CraftSkeletonHorse extends CraftAbstractHorse implements SkeletonHo
2022-01-01 04:05:42 +01:00
public void setTrapTime(int trapTime) {
this.getHandle().trapTime = trapTime;
2021-06-11 14:02:28 +02:00
}
+
2022-01-01 04:05:42 +01:00
+ // Paper start - replaced by above methods
2021-06-11 14:02:28 +02:00
+ @Override
+ public boolean isTrap() {
+ return getHandle().isTrap();
+ }
+
+ @Override
+ public void setTrap(boolean trap) {
+ getHandle().setTrap(trap);
+ }
+ // Paper end
}