mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-18 08:57:44 +01:00
Upstream has released updates that appears to apply and compile correctly Paper Changes: de5b093c Handle chunk unloading during block tick be7b4063 performance: Improve Activation Range entity iteration bacbd880 performance: Many Entity Activation Range Improvements 269394fe Update hidden-configs
108 lines
5.5 KiB
Diff
108 lines
5.5 KiB
Diff
From 6cade3e0482093105b9c690bb34594d3a991ed74 Mon Sep 17 00:00:00 2001
|
|
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
|
Date: Sun, 8 Mar 2020 20:54:44 -0500
|
|
Subject: [PATCH] Add flying mobs to entity activation range settings
|
|
|
|
---
|
|
src/main/java/org/spigotmc/ActivationRange.java | 16 +++++++++++++++-
|
|
.../java/org/spigotmc/SpigotWorldConfig.java | 2 ++
|
|
2 files changed, 17 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
|
|
index cdd2f3ba2..8864a59f7 100644
|
|
--- a/src/main/java/org/spigotmc/ActivationRange.java
|
|
+++ b/src/main/java/org/spigotmc/ActivationRange.java
|
|
@@ -10,6 +10,9 @@ import net.minecraft.server.Entity;
|
|
import net.minecraft.server.EntityAmbient;
|
|
import net.minecraft.server.EntityAnimal;
|
|
import net.minecraft.server.EntityArrow;
|
|
+import net.minecraft.server.EntityBat; // Purpur
|
|
+import net.minecraft.server.EntityBird; // Purpur
|
|
+import net.minecraft.server.EntityBlaze; // Purpur
|
|
import net.minecraft.server.EntityComplexPart;
|
|
import net.minecraft.server.EntityCreature;
|
|
import net.minecraft.server.EntityCreeper;
|
|
@@ -31,6 +34,7 @@ import net.minecraft.server.EntitySlice;
|
|
import net.minecraft.server.EntitySlime;
|
|
import net.minecraft.server.EntityTNTPrimed;
|
|
import net.minecraft.server.EntityThrownTrident;
|
|
+import net.minecraft.server.EntityVex; // Purpur
|
|
import net.minecraft.server.EntityVillager;
|
|
import net.minecraft.server.EntityWither;
|
|
import net.minecraft.server.MathHelper;
|
|
@@ -49,6 +53,7 @@ public class ActivationRange
|
|
|
|
public enum ActivationType
|
|
{
|
|
+ FLYING, // Purpur
|
|
WATER, // Paper
|
|
MONSTER,
|
|
ANIMAL,
|
|
@@ -69,6 +74,7 @@ public class ActivationRange
|
|
*/
|
|
public static ActivationType initializeEntityActivationType(Entity entity)
|
|
{
|
|
+ if (isFlyingMob(entity)) { return ActivationType.FLYING; } // Purpur
|
|
if (entity instanceof EntityWaterAnimal) { return ActivationType.WATER; } // Paper
|
|
if ( entity instanceof EntityRaider )
|
|
{
|
|
@@ -132,6 +138,7 @@ public class ActivationRange
|
|
final int animalActivationRange = world.spigotConfig.animalActivationRange;
|
|
final int monsterActivationRange = world.spigotConfig.monsterActivationRange;
|
|
final int waterActivationRange = world.spigotConfig.waterActivationRange; // Paper
|
|
+ final int flyingActivationRange = world.spigotConfig.flyingActivationRange; // Purpur
|
|
final ChunkProviderServer chunkProvider = (ChunkProviderServer) world.getChunkProvider(); // Paper
|
|
|
|
int maxRange = Math.max( monsterActivationRange, animalActivationRange );
|
|
@@ -150,6 +157,7 @@ public class ActivationRange
|
|
ActivationType.ANIMAL.boundingBox = player.getBoundingBox().grow( animalActivationRange, 256, animalActivationRange );
|
|
ActivationType.MONSTER.boundingBox = player.getBoundingBox().grow( monsterActivationRange, 256, monsterActivationRange );
|
|
ActivationType.WATER.boundingBox = player.getBoundingBox().grow( waterActivationRange, 256, waterActivationRange ); // Paper
|
|
+ ActivationType.FLYING.boundingBox = player.getBoundingBox().grow( flyingActivationRange, 256, flyingActivationRange ); // Purpur
|
|
|
|
|
|
int i = MathHelper.floor( maxBB.minX / 16.0D );
|
|
@@ -211,7 +219,7 @@ public class ActivationRange
|
|
}
|
|
if ( !( entity instanceof EntityArrow ) )
|
|
{
|
|
- if ( (!entity.onGround && !(entity instanceof EntityFlying)) || !entity.passengers.isEmpty() || entity.isPassenger() ) // Paper
|
|
+ if ( (!entity.onGround && !isFlyingMob(entity)) || !entity.passengers.isEmpty() || entity.isPassenger() ) // Paper // Purpur
|
|
{
|
|
return 10; // Paper
|
|
}
|
|
@@ -310,4 +318,10 @@ public class ActivationRange
|
|
}
|
|
return isActive;
|
|
}
|
|
+
|
|
+ // Purpur start
|
|
+ public static boolean isFlyingMob(Entity entity) {
|
|
+ return entity instanceof EntityBat || entity instanceof EntityBird || entity instanceof EntityFlying || entity instanceof EntityBlaze || entity instanceof EntityVex;
|
|
+ }
|
|
+ // Purpur end
|
|
}
|
|
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
|
index 3ceeed3f9..9a3f566a9 100644
|
|
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
|
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
|
@@ -181,6 +181,7 @@ public class SpigotWorldConfig
|
|
public int raiderActivationRange = 48;
|
|
public int miscActivationRange = 16;
|
|
public int waterActivationRange = 16; // Paper
|
|
+ public int flyingActivationRange = 128; // Purpur
|
|
public boolean tickInactiveVillagers = true;
|
|
private void activationRange()
|
|
{
|
|
@@ -189,6 +190,7 @@ public class SpigotWorldConfig
|
|
raiderActivationRange = getInt( "entity-activation-range.raiders", raiderActivationRange );
|
|
miscActivationRange = getInt( "entity-activation-range.misc", miscActivationRange );
|
|
waterActivationRange = getInt( "entity-activation-range.water", waterActivationRange ); // Paper
|
|
+ flyingActivationRange = getInt( "entity-activation-range.flying", flyingActivationRange ); // Purpur
|
|
tickInactiveVillagers = getBoolean( "entity-activation-range.tick-inactive-villagers", tickInactiveVillagers );
|
|
log( "Entity Activation Range: An " + animalActivationRange + " / Mo " + monsterActivationRange + " / Ra " + raiderActivationRange + " / Mi " + miscActivationRange + " / Tiv " + tickInactiveVillagers );
|
|
}
|
|
--
|
|
2.24.0
|
|
|