testserver/patches/server/0233-SkeletonHorse-Addition...

111 lines
5.4 KiB
Diff
Raw Normal View History

2021-06-11 12:02:28 +00: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/SkeletonHorse.java b/src/main/java/net/minecraft/world/entity/animal/horse/SkeletonHorse.java
2021-06-12 23:45:00 +00:00
index b5446b417963850f25c715abe52403c731b6ef01..9c5c7ef3b915afe5fe54144f51e383a83c1eb752 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/net/minecraft/world/entity/animal/horse/SkeletonHorse.java
+++ b/src/main/java/net/minecraft/world/entity/animal/horse/SkeletonHorse.java
2021-06-12 23:45:00 +00:00
@@ -23,7 +23,7 @@ public class SkeletonHorse extends AbstractHorse {
2021-06-11 12:02:28 +00:00
private final SkeletonTrapGoal skeletonTrapGoal = new SkeletonTrapGoal(this);
2021-06-12 23:45:00 +00:00
private static final int TRAP_MAX_LIFE = 18000;
2021-06-11 12:02:28 +00:00
private boolean isTrap;
- private int trapTime;
2021-06-12 23:45:00 +00:00
+ public int trapTime; // Paper private -> public
2021-06-11 12:02:28 +00:00
public SkeletonHorse(EntityType<? extends SkeletonHorse> type, Level world) {
super(type, world);
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
2021-06-12 23:45:00 +00:00
index 67afaab789041f49407233ca8a856a3b0131fcf6..1b874f8a72f5b1ac64dd66621b039295f5dc1f18 100644
2021-06-11 12:02:28 +00: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
2021-06-12 23:45:00 +00:00
@@ -18,6 +18,7 @@ import net.minecraft.world.level.Level;
2021-06-11 12:02:28 +00:00
public class SkeletonTrapGoal extends Goal {
private final SkeletonHorse horse;
2021-06-12 23:45:00 +00:00
+ private java.util.List<org.bukkit.entity.HumanEntity> eligiblePlayers; // Paper
2021-06-11 12:02:28 +00:00
public SkeletonTrapGoal(SkeletonHorse skeletonHorse) {
this.horse = skeletonHorse;
2021-06-12 23:45:00 +00:00
@@ -25,12 +26,13 @@ public class SkeletonTrapGoal extends Goal {
2021-06-11 12:02:28 +00:00
@Override
public boolean canUse() {
- return this.horse.level.hasNearbyAlivePlayer(this.horse.getX(), this.horse.getY(), this.horse.getZ(), 10.0D);
+ return !(eligiblePlayers = this.horse.level.findNearbyBukkitPlayers(this.horse.getX(), this.horse.getY(), this.horse.getZ(), 10.0D, false)).isEmpty(); // Paper
}
@Override
public void tick() {
ServerLevel worldserver = (ServerLevel) this.horse.level;
+ 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
2021-06-12 23:45:00 +00:00
index 0b6e5ee9872a73823219bff7f642375fdc4ec243..b0cafe6e0bdb3f297c13f310fdbe9e3158a6715d 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/net/minecraft/world/level/EntityGetter.java
+++ b/src/main/java/net/minecraft/world/level/EntityGetter.java
2021-06-12 23:45:00 +00:00
@@ -90,6 +90,28 @@ public interface EntityGetter {
return player;
2021-06-11 12:02:28 +00:00
}
+ // Paper start
2021-06-12 23:45:00 +00: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 12:02:28 +00:00
+ }
+
2021-06-12 23:45:00 +00: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 12:02:28 +00:00
+
+ for (Player human : this.players()) {
+ if (predicate == null || predicate.test(human)) {
+ double distanceSquared = human.getDistanceSquared(x, y, z);
+
+ 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
2021-06-12 23:45:00 +00:00
index b52ca4a612e30542ef4029cb1340f616bc4c36e6..90a61d1472afea12637814256f91dbd2f5acb42e 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeletonHorse.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeletonHorse.java
@@ -25,4 +25,26 @@ public class CraftSkeletonHorse extends CraftAbstractHorse implements SkeletonHo
public Variant getVariant() {
return Variant.SKELETON_HORSE;
}
+
+ // Paper start
+ @Override
+ public net.minecraft.world.entity.animal.horse.SkeletonHorse getHandle() {
+ return (net.minecraft.world.entity.animal.horse.SkeletonHorse) super.getHandle();
+ }
+
+ @Override
+ public int getTrapTime() {
2021-06-12 23:45:00 +00:00
+ return getHandle().trapTime;
2021-06-11 12:02:28 +00:00
+ }
+
+ @Override
+ public boolean isTrap() {
+ return getHandle().isTrap();
+ }
+
+ @Override
+ public void setTrap(boolean trap) {
+ getHandle().setTrap(trap);
+ }
+ // Paper end
}