From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Xymb Date: Sat, 17 Jun 2023 19:52:29 +0300 Subject: [PATCH] Swap distanceToSqr and target test diff --git a/src/main/java/net/minecraft/world/level/EntityGetter.java b/src/main/java/net/minecraft/world/level/EntityGetter.java index b1a6a66ed02706c1adc36dcedfa415f5a24a25a0..97a5eca200fd606d6102e40f9b8c32c2e7652cf9 100644 --- a/src/main/java/net/minecraft/world/level/EntityGetter.java +++ b/src/main/java/net/minecraft/world/level/EntityGetter.java @@ -99,9 +99,9 @@ public interface EntityGetter { Player player = null; for(Player player2 : this.getLocalPlayers()) { // Folia - region threading - if (targetPredicate == null || targetPredicate.test(player2)) { + if (true || targetPredicate == null || targetPredicate.test(player2)) { // Kaiiju - Move this down double e = player2.distanceToSqr(x, y, z); - if ((maxDistance < 0.0D || e < maxDistance * maxDistance) && (d == -1.0D || e < d)) { + if ((maxDistance < 0.0D || e < maxDistance * maxDistance) && (d == -1.0D || e < d) && (targetPredicate == null || targetPredicate.test(player2))) { // Kaiiju d = e; player = player2; } @@ -147,9 +147,10 @@ public interface EntityGetter { // Paper start default boolean hasNearbyAlivePlayerThatAffectsSpawning(double x, double y, double z, double range) { for (Player player : this.getLocalPlayers()) { // Folia - region threading - if (EntitySelector.PLAYER_AFFECTS_SPAWNING.test(player)) { // combines NO_SPECTATORS and LIVING_ENTITY_STILL_ALIVE with an "affects spawning" check + if (true || EntitySelector.PLAYER_AFFECTS_SPAWNING.test(player)) { // combines NO_SPECTATORS and LIVING_ENTITY_STILL_ALIVE with an "affects spawning" check // Kaiiju - Move this down double distanceSqr = player.distanceToSqr(x, y, z); if (range < 0.0D || distanceSqr < range * range) { + if (EntitySelector.PLAYER_AFFECTS_SPAWNING.test(player)) // Kaiiju return true; } } @@ -199,9 +200,9 @@ public interface EntityGetter { T livingEntity = null; for(T livingEntity2 : entityList) { - if (targetPredicate.test(entity, livingEntity2)) { + if (true || targetPredicate.test(entity, livingEntity2)) { // Kaiiju - Move this down double e = livingEntity2.distanceToSqr(x, y, z); - if (d == -1.0D || e < d) { + if ((d == -1.0D || e < d) && targetPredicate.test(entity, livingEntity2)) { // Kaiiju d = e; livingEntity = livingEntity2; }