aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches/0364-Backport-Water-Activation-Range.patch
blob: 5fb09a840c88bc604a09f8fa0c52ac45e50f27fd (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
From dc1b736e06fa15ed7a6f3501f306da089bd1c4f7 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 6 Oct 2018 01:10:21 -0400
Subject: [PATCH] Backport Water Activation Range

Adds Entity Activation Range for water mobs
and no longer gives immunity to mobs (squid) that know how to
pathfind in water.

diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
index 33ae738908..4c8d94c877 100644
--- a/src/main/java/org/spigotmc/ActivationRange.java
+++ b/src/main/java/org/spigotmc/ActivationRange.java
@@ -19,6 +19,7 @@ import net.minecraft.server.EntityFallingBlock;
 import net.minecraft.server.EntityFireball;
 import net.minecraft.server.EntityFireworks;
 import net.minecraft.server.EntityHuman;
+import net.minecraft.server.EntityInsentient;
 import net.minecraft.server.EntityLiving;
 import net.minecraft.server.EntityLlama;
 import net.minecraft.server.EntityMonster;
@@ -27,11 +28,13 @@ import net.minecraft.server.EntitySheep;
 import net.minecraft.server.EntitySlime;
 import net.minecraft.server.EntityTNTPrimed;
 import net.minecraft.server.EntityVillager;
+import net.minecraft.server.EntityWaterAnimal;
 import net.minecraft.server.EntityWeather;
 import net.minecraft.server.EntityWither;
 import net.minecraft.server.MCUtil;
 import net.minecraft.server.MathHelper;
 import net.minecraft.server.MinecraftServer;
+import net.minecraft.server.NavigationGuardian;
 import net.minecraft.server.World;
 
 public class ActivationRange
@@ -40,6 +43,7 @@ public class ActivationRange
     static AxisAlignedBB maxBB = new AxisAlignedBB( 0, 0, 0, 0, 0, 0 );
     static AxisAlignedBB miscBB = new AxisAlignedBB( 0, 0, 0, 0, 0, 0 );
     static AxisAlignedBB animalBB = new AxisAlignedBB( 0, 0, 0, 0, 0, 0 );
+    static AxisAlignedBB waterBB = new AxisAlignedBB( 0, 0, 0, 0, 0, 0 ); // Paper
     static AxisAlignedBB monsterBB = new AxisAlignedBB( 0, 0, 0, 0, 0, 0 );
 
     /**
@@ -51,6 +55,7 @@ public class ActivationRange
      */
     public static byte initializeEntityActivationType(Entity entity)
     {
+        if (entity instanceof EntityWaterAnimal) { return 4; } // Paper
         if ( entity instanceof EntityMonster || entity instanceof EntitySlime )
         {
             return 1; // Monster
@@ -75,6 +80,7 @@ public class ActivationRange
         if ( ( entity.activationType == 3 && config.miscActivationRange == 0 )
                 || ( entity.activationType == 2 && config.animalActivationRange == 0 )
                 || ( entity.activationType == 1 && config.monsterActivationRange == 0 )
+                || ( entity.activationType == 4 && config.waterActivationRange == 0 ) // Paper
                 || entity instanceof EntityHuman
                 || entity instanceof EntityProjectile
                 || entity instanceof EntityEnderDragon
@@ -105,6 +111,7 @@ public class ActivationRange
         final int miscActivationRange = world.spigotConfig.miscActivationRange;
         final int animalActivationRange = world.spigotConfig.animalActivationRange;
         final int monsterActivationRange = world.spigotConfig.monsterActivationRange;
+        final int waterActivationRange = world.spigotConfig.waterActivationRange; // Paper
 
         int maxRange = Math.max( monsterActivationRange, animalActivationRange );
         maxRange = Math.max( maxRange, miscActivationRange );
@@ -118,6 +125,7 @@ public class ActivationRange
             maxBB = player.getBoundingBox().grow( maxRange, 256, maxRange );
             miscBB = player.getBoundingBox().grow( miscActivationRange, 256, miscActivationRange );
             animalBB = player.getBoundingBox().grow( animalActivationRange, 256, animalActivationRange );
+            waterBB = player.getBoundingBox().grow( waterActivationRange, 256, waterActivationRange ); // Paper
             monsterBB = player.getBoundingBox().grow( monsterActivationRange, 256, monsterActivationRange );
 
             int i = MathHelper.floor( maxBB.a / 16.0D );
@@ -171,6 +179,14 @@ public class ActivationRange
                                 entity.activatedTick = MinecraftServer.currentTick;
                             }
                             break;
+                            // Paper start
+                        case 4:
+                            if ( waterBB.c( entity.getBoundingBox() ) )
+                            {
+                                entity.activatedTick = MinecraftServer.currentTick;
+                            }
+                            break;
+                            // Paper end
                         case 3:
                         default:
                             if ( miscBB.c( entity.getBoundingBox() ) )
@@ -192,11 +208,14 @@ public class ActivationRange
      */
     public static boolean checkEntityImmunities(Entity entity)
     {
-        // quick checks.
-        if ( entity.inWater || entity.fireTicks > 0 )
-        {
+        // Paper start - optimize Water cases
+        if ((entity.inWater && (!(entity instanceof EntityInsentient) || !(((EntityInsentient) entity).getNavigation() instanceof NavigationGuardian)))) {
+            return true;
+        }
+        if (entity.fireTicks > 0) {
             return true;
         }
+        // Paper end
         if ( !( entity instanceof EntityArrow ) )
         {
             if ( !entity.onGround || !entity.passengers.isEmpty() || entity.isPassenger() )
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
index 66c399a260..f872c1554d 100644
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
@@ -144,12 +144,14 @@ public class SpigotWorldConfig
     public int animalActivationRange = 32;
     public int monsterActivationRange = 32;
     public int miscActivationRange = 16;
+    public int waterActivationRange = 16; // Paper
     public boolean tickInactiveVillagers = true;
     private void activationRange()
     {
         animalActivationRange = getInt( "entity-activation-range.animals", animalActivationRange );
         monsterActivationRange = getInt( "entity-activation-range.monsters", monsterActivationRange );
         miscActivationRange = getInt( "entity-activation-range.misc", miscActivationRange );
+        waterActivationRange = getInt( "entity-activation-range.water", waterActivationRange ); // Paper
         tickInactiveVillagers = getBoolean( "entity-activation-range.tick-inactive-villagers", tickInactiveVillagers );
         log( "Entity Activation Range: An " + animalActivationRange + " / Mo " + monsterActivationRange + " / Mi " + miscActivationRange + " / Tiv " + tickInactiveVillagers );
     }
-- 
2.19.0