aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches/0426-Tracking-Range-Improvements.patch
blob: 01f06e48beaf53fef6fd6d0e29af6bb0f0a81775 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: kickash32 <kickash32@gmail.com>
Date: Sat, 21 Dec 2019 15:22:09 -0500
Subject: [PATCH] Tracking Range Improvements

Sets tracking range of watermobs to animals instead of misc and simplifies code

Also ignores Enderdragon, defaulting it to Mojang's setting

diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
index c20acd86beb8f28345d1359d0a2b68b7d8e0e410..4ba661c5a89bebe29c8802387bc93c10094b7606 100644
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
@@ -1702,6 +1702,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
             while (iterator.hasNext()) {
                 Entity entity = (Entity) iterator.next();
                 int j = entity.getEntityType().getChunkRange() * 16;
+                j = org.spigotmc.TrackingRange.getEntityTrackingRange(entity, j); // Paper
 
                 if (j > i) {
                     i = j;
diff --git a/src/main/java/org/spigotmc/TrackingRange.java b/src/main/java/org/spigotmc/TrackingRange.java
index 6f8e6c1d079f82d7706d0b4f710bfb9b50e209d9..03990231a8b6bc6925f054e9033825316abfafcc 100644
--- a/src/main/java/org/spigotmc/TrackingRange.java
+++ b/src/main/java/org/spigotmc/TrackingRange.java
@@ -1,6 +1,8 @@
 package org.spigotmc;
 
 import net.minecraft.server.Entity;
+import net.minecraft.server.EntityEnderDragon; // Paper
+import net.minecraft.server.WorldServer; // Paper
 import net.minecraft.server.EntityExperienceOrb;
 import net.minecraft.server.EntityGhast;
 import net.minecraft.server.EntityItem;
@@ -25,26 +27,26 @@ public class TrackingRange
         if ( entity instanceof EntityPlayer )
         {
             return config.playerTrackingRange;
-        }  else if ( entity.activationType == ActivationRange.ActivationType.MONSTER || entity.activationType == ActivationRange.ActivationType.RAIDER )
-        {
-            return config.monsterTrackingRange;
-        } else if ( entity instanceof EntityGhast )
-        {
-            if ( config.monsterTrackingRange > config.monsterActivationRange )
-            {
+        // Paper start - Simplify and set water mobs to animal tracking range
+        }
+        switch (entity.activationType) {
+            case RAIDER:
+            case MONSTER:
+            case FLYING_MONSTER:
                 return config.monsterTrackingRange;
-            } else
-            {
-                return config.monsterActivationRange;
-            }
-        } else if ( entity.activationType == ActivationRange.ActivationType.ANIMAL )
-        {
-            return config.animalTrackingRange;
-        } else if ( entity instanceof EntityItemFrame || entity instanceof EntityPainting || entity instanceof EntityItem || entity instanceof EntityExperienceOrb )
+            case WATER:
+            case VILLAGER:
+            case ANIMAL:
+                return config.animalTrackingRange;
+            case MISC:
+        }
+        if ( entity instanceof EntityItemFrame || entity instanceof EntityPainting || entity instanceof EntityItem || entity instanceof EntityExperienceOrb )
+        // Paper end
         {
             return config.miscTrackingRange;
         } else
         {
+            if (entity instanceof EntityEnderDragon) return ((WorldServer)(entity.getWorld())).getChunkProvider().playerChunkMap.getLoadViewDistance(); // Paper - enderdragon is exempt
             return config.otherTrackingRange;
         }
     }