mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-30 06:24:06 +01:00
Fix lag caused by water mobs across the board - Fixes #1462
This update introduces Entity Activation Range for water mobs. Activation Range has been one of my biggest performance improvements I ever added to Minecraft, however "Entity is in Water" is an immunity case that keeps an entity active. This update ignores the water check for known water based mobs, allowing them to actually go inactive. In addition to that, a new config option was added to spigot.yml to go with the rest of the entity-activation-range options to let you configure aquatic mobs like fish, squid and dolphins separately. This should overall fix all lag caused by water mobs.
This commit is contained in:
parent
aad2e08482
commit
d7dd3798ec
@ -1,10 +1,12 @@
|
|||||||
From 41be89ac350a161565254c71c675b9b3f06d6021 Mon Sep 17 00:00:00 2001
|
From 5c8d5740834de57a88322d4bdb1a0fb33831dc29 Mon Sep 17 00:00:00 2001
|
||||||
From: Aikar <aikar@aikar.co>
|
From: Aikar <aikar@aikar.co>
|
||||||
Date: Tue, 27 Dec 2016 22:38:06 -0500
|
Date: Tue, 27 Dec 2016 22:38:06 -0500
|
||||||
Subject: [PATCH] Activation Range Improvements
|
Subject: [PATCH] Activation Range Improvements
|
||||||
|
|
||||||
Fixes and adds new Immunities to improve gameplay behavior
|
Fixes and adds new Immunities to improve gameplay behavior
|
||||||
|
|
||||||
|
Adds water Mobs to activation range config and nerfs fish
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/BlockPosition.java b/src/main/java/net/minecraft/server/BlockPosition.java
|
diff --git a/src/main/java/net/minecraft/server/BlockPosition.java b/src/main/java/net/minecraft/server/BlockPosition.java
|
||||||
index f4ed98d2d9..1dfd71df0a 100644
|
index f4ed98d2d9..1dfd71df0a 100644
|
||||||
--- a/src/main/java/net/minecraft/server/BlockPosition.java
|
--- a/src/main/java/net/minecraft/server/BlockPosition.java
|
||||||
@ -110,18 +112,105 @@ index 9a75cb63ba..cf10605aaa 100644
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
|
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
|
||||||
index f9bb19fed6..03ca577b4c 100644
|
index f9bb19fed6..d176008f44 100644
|
||||||
--- a/src/main/java/org/spigotmc/ActivationRange.java
|
--- a/src/main/java/org/spigotmc/ActivationRange.java
|
||||||
+++ b/src/main/java/org/spigotmc/ActivationRange.java
|
+++ b/src/main/java/org/spigotmc/ActivationRange.java
|
||||||
@@ -20,6 +20,7 @@ import net.minecraft.server.EntityFireball;
|
@@ -13,13 +13,16 @@ import net.minecraft.server.EntityArrow;
|
||||||
|
import net.minecraft.server.EntityComplexPart;
|
||||||
|
import net.minecraft.server.EntityCreature;
|
||||||
|
import net.minecraft.server.EntityCreeper;
|
||||||
|
+import net.minecraft.server.EntityDrowned;
|
||||||
|
import net.minecraft.server.EntityEnderCrystal;
|
||||||
|
import net.minecraft.server.EntityEnderDragon;
|
||||||
|
import net.minecraft.server.EntityFallingBlock;
|
||||||
|
import net.minecraft.server.EntityFireball;
|
||||||
import net.minecraft.server.EntityFireworks;
|
import net.minecraft.server.EntityFireworks;
|
||||||
|
+import net.minecraft.server.EntityFish;
|
||||||
import net.minecraft.server.EntityHuman;
|
import net.minecraft.server.EntityHuman;
|
||||||
import net.minecraft.server.EntityLiving;
|
import net.minecraft.server.EntityLiving;
|
||||||
+import net.minecraft.server.EntityLlama;
|
+import net.minecraft.server.EntityLlama;
|
||||||
import net.minecraft.server.EntityMonster;
|
import net.minecraft.server.EntityMonster;
|
||||||
import net.minecraft.server.EntityProjectile;
|
import net.minecraft.server.EntityProjectile;
|
||||||
import net.minecraft.server.EntitySheep;
|
import net.minecraft.server.EntitySheep;
|
||||||
@@ -212,18 +213,29 @@ public class ActivationRange
|
@@ -27,6 +30,7 @@ import net.minecraft.server.EntitySlime;
|
||||||
|
import net.minecraft.server.EntityTNTPrimed;
|
||||||
|
import net.minecraft.server.EntityThrownTrident;
|
||||||
|
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;
|
||||||
|
@@ -40,6 +44,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 +56,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 +81,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
|
||||||
|
@@ -106,6 +113,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 );
|
||||||
|
@@ -119,6 +127,7 @@ public class ActivationRange
|
||||||
|
maxBB = player.getBoundingBox().grow( playerMaxRange, 256, playerMaxRange ); // Paper - Use player view distance API
|
||||||
|
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 );
|
||||||
|
@@ -172,6 +181,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() ) )
|
||||||
|
@@ -193,8 +210,13 @@ public class ActivationRange
|
||||||
|
*/
|
||||||
|
public static boolean checkEntityImmunities(Entity entity)
|
||||||
|
{
|
||||||
|
+ // Paper start - optimize Water cases
|
||||||
|
+ if (entity instanceof EntityFish) {
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
// quick checks.
|
||||||
|
- if ( entity.inWater || entity.fireTicks > 0 )
|
||||||
|
+ if ( (entity.inWater && (!(entity instanceof EntityWaterAnimal || entity instanceof EntityDrowned))) || entity.fireTicks > 0 )
|
||||||
|
+ // Paper end
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@@ -212,18 +234,29 @@ public class ActivationRange
|
||||||
if ( entity instanceof EntityLiving )
|
if ( entity instanceof EntityLiving )
|
||||||
{
|
{
|
||||||
EntityLiving living = (EntityLiving) entity;
|
EntityLiving living = (EntityLiving) entity;
|
||||||
@ -154,7 +243,7 @@ index f9bb19fed6..03ca577b4c 100644
|
|||||||
if ( entity instanceof EntityAnimal )
|
if ( entity instanceof EntityAnimal )
|
||||||
{
|
{
|
||||||
EntityAnimal animal = (EntityAnimal) entity;
|
EntityAnimal animal = (EntityAnimal) entity;
|
||||||
@@ -276,10 +288,10 @@ public class ActivationRange
|
@@ -276,10 +309,10 @@ public class ActivationRange
|
||||||
{
|
{
|
||||||
isActive = false;
|
isActive = false;
|
||||||
}
|
}
|
||||||
@ -168,6 +257,25 @@ index f9bb19fed6..03ca577b4c 100644
|
|||||||
if ( isActive && !( chunk != null && chunk.areNeighborsLoaded( 1 ) ) )
|
if ( isActive && !( chunk != null && chunk.areNeighborsLoaded( 1 ) ) )
|
||||||
{
|
{
|
||||||
isActive = false;
|
isActive = false;
|
||||||
|
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||||
|
index 87bc8e2d9c..06d84a0b66 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
|
2.19.0
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user