From c9f40df758e303b61dfb17361f31b1ee308529b0 Mon Sep 17 00:00:00 2001 From: Mgazul Date: Mon, 18 Sep 2023 00:30:46 +0800 Subject: [PATCH] Fixed #2511 --- src/main/java/org/spigotmc/TrackingRange.java | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/spigotmc/TrackingRange.java b/src/main/java/org/spigotmc/TrackingRange.java index 8471faf966..efc226db90 100644 --- a/src/main/java/org/spigotmc/TrackingRange.java +++ b/src/main/java/org/spigotmc/TrackingRange.java @@ -20,24 +20,22 @@ public class TrackingRange { */ public static int getEntityTrackingRange(Entity entity, int defaultRange) { SpigotWorldConfig config = entity.world.spigotConfig; - int range = defaultRange; if (entity instanceof EntityPlayerMP) { - range = config.playerTrackingRange; - } else if (entity.defaultActivationState || entity instanceof EntityGhast) { - range = defaultRange; + return config.playerTrackingRange; } else if (entity.activationType == 1) { - range = config.monsterTrackingRange; + return config.monsterTrackingRange; + } else if (entity instanceof EntityGhast) { + return config.monsterTrackingRange > config.monsterActivationRange ? config.monsterTrackingRange : config.monsterActivationRange; } else if (entity.activationType == 2) { - range = config.animalTrackingRange; - } else if (entity instanceof EntityItemFrame || entity instanceof EntityPainting || entity instanceof EntityItem || entity instanceof EntityXPOrb) { - range = config.miscTrackingRange; + return config.animalTrackingRange; + } else { + return !(entity instanceof EntityItemFrame) + && !(entity instanceof EntityPainting) + && !(entity instanceof EntityItem) + && !(entity instanceof EntityXPOrb) + ? config.otherTrackingRange + : config.miscTrackingRange; } - // Cauldron start - allow for 0 to disable tracking ranges - if (range == 0) { - return defaultRange; - } - // Cauldron end - - return Math.min(config.otherTrackingRange, range); } + }