Activation Range

This commit is contained in:
md_5 2013-06-20 19:00:26 +10:00
parent 9d2daf140b
commit 1176626e5e

View File

@ -1,4 +1,4 @@
From b09d78b7f1cb674b6dffba57888d241c94ee16c6 Mon Sep 17 00:00:00 2001 From 118a860a1790b95d1992033d9735aaa8c3e405af Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co> From: Aikar <aikar@aikar.co>
Date: Sun, 3 Feb 2013 05:10:21 -0500 Date: Sun, 3 Feb 2013 05:10:21 -0500
Subject: [PATCH] Entity Activation Range Subject: [PATCH] Entity Activation Range
@ -9,7 +9,7 @@ This will drastically cut down on tick timings for entities that are not in rang
This change can have dramatic impact on gameplay if configured too low. Balance according to your servers desired gameplay. This change can have dramatic impact on gameplay if configured too low. Balance according to your servers desired gameplay.
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 978b6ef..401edcc 100644 index 978b6ef..438a26a 100644
--- a/src/main/java/net/minecraft/server/Entity.java --- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java
@@ -88,7 +88,7 @@ public abstract class Entity { @@ -88,7 +88,7 @@ public abstract class Entity {
@ -28,7 +28,7 @@ index 978b6ef..401edcc 100644
+ // Spigot start + // Spigot start
public CustomTimingsHandler tickTimer = org.bukkit.craftbukkit.SpigotTimings.getEntityTimings(this); // Spigot public CustomTimingsHandler tickTimer = org.bukkit.craftbukkit.SpigotTimings.getEntityTimings(this); // Spigot
+ public final byte activationType = org.bukkit.craftbukkit.Spigot.initializeEntityActivationType(this); + public final byte activationType = org.spigotmc.ActivationRange.initializeEntityActivationType(this);
+ public final boolean defaultActivationState; + public final boolean defaultActivationState;
+ public long activatedTick = 0; + public long activatedTick = 0;
+ public void inactiveTick() { } + public void inactiveTick() { }
@ -42,7 +42,7 @@ index 978b6ef..401edcc 100644
if (world != null) { if (world != null) {
this.dimension = world.worldProvider.dimension; this.dimension = world.worldProvider.dimension;
+ // Spigot start + // Spigot start
+ this.defaultActivationState = org.bukkit.craftbukkit.Spigot.initializeEntityActivationState(this, world.getWorld()); + this.defaultActivationState = org.spigotmc.ActivationRange.initializeEntityActivationState(this, world.spigotConfig);
+ } else { + } else {
+ this.defaultActivationState = false; + this.defaultActivationState = false;
} }
@ -118,33 +118,25 @@ index 58a4acb..35f3fea 100644
public EntityLiving(World world) { public EntityLiving(World world) {
super(world); super(world);
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 3c6b51a..6de55ba 100644 index d4d8f04..435ec52 100644
--- a/src/main/java/net/minecraft/server/World.java --- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java
@@ -13,6 +13,7 @@ import java.util.concurrent.Callable; @@ -1277,6 +1277,7 @@ public abstract class World implements IBlockAccess {
// CraftBukkit start
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.util.LongHashSet;
+import org.bukkit.craftbukkit.Spigot; // Spigot
import org.bukkit.craftbukkit.SpigotTimings; // Spigot
import org.bukkit.craftbukkit.util.UnsafeList;
import org.bukkit.generator.ChunkGenerator;
@@ -1275,6 +1276,7 @@ public abstract class World implements IBlockAccess {
this.f.clear(); this.f.clear();
this.methodProfiler.c("regular"); this.methodProfiler.c("regular");
+ org.bukkit.craftbukkit.Spigot.activateEntities(this); // Spigot + org.spigotmc.ActivationRange.activateEntities(this); // Spigot
timings.entityTick.startTiming(); // Spigot timings.entityTick.startTiming(); // Spigot
for (i = 0; i < this.entityList.size(); ++i) { for (i = 0; i < this.entityList.size(); ++i) {
entity = (Entity) this.entityList.get(i); entity = (Entity) this.entityList.get(i);
@@ -1435,8 +1437,13 @@ public abstract class World implements IBlockAccess { @@ -1437,8 +1438,13 @@ public abstract class World implements IBlockAccess {
int j = MathHelper.floor(entity.locZ); int j = MathHelper.floor(entity.locZ);
byte b0 = 32; byte b0 = 32;
- if (!flag || this.e(i - b0, 0, j - b0, i + b0, 0, j + b0)) { - if (!flag || this.e(i - b0, 0, j - b0, i + b0, 0, j + b0)) {
- entity.tickTimer.startTiming(); // Spigot - entity.tickTimer.startTiming(); // Spigot
+ // Spigot start + // Spigot start
+ if (!Spigot.checkIfActive(entity)) { + if (!org.spigotmc.ActivationRange.checkIfActive(entity)) {
+ entity.ticksLived++; + entity.ticksLived++;
+ entity.inactiveTick(); + entity.inactiveTick();
+ } else { + } else {
@ -153,65 +145,28 @@ index 3c6b51a..6de55ba 100644
entity.U = entity.locX; entity.U = entity.locX;
entity.V = entity.locY; entity.V = entity.locY;
entity.W = entity.locZ; entity.W = entity.locZ;
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java diff --git a/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java b/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java
index 0a39ed3..ebf1a67 100644 index f6e507e..4328ecf 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java --- a/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java
@@ -85,6 +85,10 @@ public class CraftWorld implements World { @@ -29,6 +29,9 @@ public class SpigotTimings {
public double expMergeRadius = 3.5;
public int viewDistance;
public boolean obfuscated = false;
+ // Activation ranges:
+ public int miscEntityActivationRange = 16;
+ public int animalEntityActivationRange = 32;
+ public int monsterEntityActivationRange = 32;
// Spigot end
// Spigot start public static final CustomTimingsHandler playerCommandTimer = new CustomTimingsHandler("** playerCommand");
@@ -119,8 +123,11 @@ public class CraftWorld implements World {
sugarGrowthModifier = configuration.getInt( "world-settings.default.sugar-growth-modifier", sugarGrowthModifier );
treeGrowthModifier = configuration.getInt( "world-settings.default.tree-growth-modifier", treeGrowthModifier );
mushroomGrowthModifier = configuration.getInt( "world-settings.default.mushroom-growth-modifier", mushroomGrowthModifier );
- itemMergeRadius = configuration.getDouble("world-settings.default.item-merge-radius", itemMergeRadius);
- expMergeRadius = configuration.getDouble("world-settings.default.exp-merge-radius", expMergeRadius);
+ itemMergeRadius = configuration.getDouble( "world-settings.default.item-merge-radius", itemMergeRadius );
+ expMergeRadius = configuration.getDouble( "world-settings.default.exp-merge-radius", expMergeRadius );
+ miscEntityActivationRange = configuration.getInt( "world-settings.default.entity-activation-range-misc" );
+ animalEntityActivationRange = configuration.getInt( "world-settings.default.entity-activation-range-animals" );
+ monsterEntityActivationRange = configuration.getInt( "world-settings.default.entity-activation-range-monsters" );
// Override defaults with world specific, if they exist + public static final CustomTimingsHandler entityActivationCheckTimer = new CustomTimingsHandler("entityActivationCheck");
info = configuration.getBoolean( "world-settings." + name + ".info", info ); + public static final CustomTimingsHandler checkIfActiveTimer = new CustomTimingsHandler("** checkIfActive");
@@ -135,8 +142,11 @@ public class CraftWorld implements World { +
sugarGrowthModifier = configuration.getInt( "world-settings." + name + ".sugar-growth-modifier", sugarGrowthModifier ); public static final HashMap<String, CustomTimingsHandler> entityTypeTimingMap = new HashMap<String, CustomTimingsHandler>();
treeGrowthModifier = configuration.getInt( "world-settings." + name + ".tree-growth-modifier", treeGrowthModifier ); public static final HashMap<String, CustomTimingsHandler> tileEntityTypeTimingMap = new HashMap<String, CustomTimingsHandler>();
mushroomGrowthModifier = configuration.getInt( "world-settings." + name + ".mushroom-growth-modifier", mushroomGrowthModifier ); public static final HashMap<String, CustomTimingsHandler> pluginTaskTimingMap = new HashMap<String, CustomTimingsHandler>();
- itemMergeRadius = configuration.getDouble("world-settings." + name + ".item-merge-radius", itemMergeRadius); diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
- expMergeRadius = configuration.getDouble("world-settings." + name + ".exp-merge-radius", expMergeRadius); new file mode 100644
+ itemMergeRadius = configuration.getDouble( "world-settings." + name + ".item-merge-radius", itemMergeRadius ); index 0000000..93ce20e
+ expMergeRadius = configuration.getDouble( "world-settings." + name + ".exp-merge-radius", expMergeRadius ); --- /dev/null
+ miscEntityActivationRange = configuration.getInt( "world-settings." + name + ".entity-activation-range-misc", miscEntityActivationRange ); +++ b/src/main/java/org/spigotmc/ActivationRange.java
+ animalEntityActivationRange = configuration.getInt( "world-settings." + name + ".entity-activation-range-animals", animalEntityActivationRange ); @@ -0,0 +1,296 @@
+ monsterEntityActivationRange = configuration.getInt( "world-settings." + name + ".entity-activation-range-monsters", monsterEntityActivationRange ); +package org.spigotmc;
+
viewDistance = Bukkit.getServer().getViewDistance();
viewDistance = configuration.getInt( "world-settings." + name + ".view-distance", viewDistance );
@@ -161,6 +171,7 @@ public class CraftWorld implements World {
server.getLogger().info( "Exp Merge Radius: " + expMergeRadius );
server.getLogger().info( "View distance: " + viewDistance );
server.getLogger().info( "Orebfuscator: " + obfuscated );
+ server.getLogger().info( "Entity Activation Range: An " + animalEntityActivationRange + " / Mo " + monsterEntityActivationRange + " / Mi " + miscEntityActivationRange );
server.getLogger().info( "-------------------------------------------------" );
}
// Spigot end
diff --git a/src/main/java/org/bukkit/craftbukkit/Spigot.java b/src/main/java/org/bukkit/craftbukkit/Spigot.java
index e5004b3..2fc33f8 100644
--- a/src/main/java/org/bukkit/craftbukkit/Spigot.java
+++ b/src/main/java/org/bukkit/craftbukkit/Spigot.java
@@ -1,12 +1,43 @@
package org.bukkit.craftbukkit;
import java.net.InetAddress;
+import java.util.ArrayList; +import java.util.ArrayList;
+import java.util.List; +import java.util.List;
+import net.minecraft.server.AxisAlignedBB; +import net.minecraft.server.AxisAlignedBB;
@ -238,33 +193,17 @@ index e5004b3..2fc33f8 100644
+import net.minecraft.server.EntityWither; +import net.minecraft.server.EntityWither;
+import net.minecraft.server.MathHelper; +import net.minecraft.server.MathHelper;
+import net.minecraft.server.MinecraftServer; +import net.minecraft.server.MinecraftServer;
import net.minecraft.server.PendingConnection;
+import net.minecraft.server.World; +import net.minecraft.server.World;
import org.bukkit.command.SimpleCommandMap; +import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.craftbukkit.SpigotTimings;
public class Spigot {
+ static AxisAlignedBB maxBB = AxisAlignedBB.a(0, 0, 0, 0, 0, 0);
+ static AxisAlignedBB miscBB = AxisAlignedBB.a(0, 0, 0, 0, 0, 0);
+ static AxisAlignedBB animalBB = AxisAlignedBB.a(0, 0, 0, 0, 0, 0);
+ static AxisAlignedBB monsterBB = AxisAlignedBB.a(0, 0, 0, 0, 0, 0);
private static boolean filterIps;
public static void initialize(CraftServer server, SimpleCommandMap commandMap, YamlConfiguration configuration) {
@@ -24,12 +55,230 @@ public class Spigot {
server.orebfuscatorDisabledWorlds = configuration.getStringList("orebfuscator.disabled-worlds");
server.orebfuscatorBlocks = configuration.getShortList("orebfuscator.blocks");
if (server.orebfuscatorEngineMode != 1 && server.orebfuscatorEngineMode != 2) {
- server.orebfuscatorEngineMode = 1;
+ server.orebfuscatorEngineMode = 1;
}
if (server.chunkGCPeriod == 0) {
server.getLogger().severe("[Spigot] You should not disable chunk-gc, unexpected behaviour may occur!");
}
+ +
+ } +public class ActivationRange
+{
+
+ static AxisAlignedBB maxBB = AxisAlignedBB.a( 0, 0, 0, 0, 0, 0 );
+ static AxisAlignedBB miscBB = AxisAlignedBB.a( 0, 0, 0, 0, 0, 0 );
+ static AxisAlignedBB animalBB = AxisAlignedBB.a( 0, 0, 0, 0, 0, 0 );
+ static AxisAlignedBB monsterBB = AxisAlignedBB.a( 0, 0, 0, 0, 0, 0 );
+ +
+ /** + /**
+ * Initializes an entities type on construction to specify what group this + * Initializes an entities type on construction to specify what group this
@ -273,12 +212,16 @@ index e5004b3..2fc33f8 100644
+ * @param entity + * @param entity
+ * @return group id + * @return group id
+ */ + */
+ public static byte initializeEntityActivationType(Entity entity) { + public static byte initializeEntityActivationType(Entity entity)
+ if (entity instanceof EntityMonster || entity instanceof EntitySlime) { + {
+ if ( entity instanceof EntityMonster || entity instanceof EntitySlime )
+ {
+ return 1; // Monster + return 1; // Monster
+ } else if (entity instanceof EntityCreature || entity instanceof EntityAmbient) { + } else if ( entity instanceof EntityCreature || entity instanceof EntityAmbient )
+ {
+ return 2; // Animal + return 2; // Animal
+ } else { + } else
+ {
+ return 3; // Misc + return 3; // Misc
+ } + }
+ } + }
@ -290,10 +233,11 @@ index e5004b3..2fc33f8 100644
+ * @param world + * @param world
+ * @return boolean If it should always tick. + * @return boolean If it should always tick.
+ */ + */
+ public static boolean initializeEntityActivationState(Entity entity, CraftWorld world) { + public static boolean initializeEntityActivationState(Entity entity, SpigotWorldConfig config)
+ if ((entity.activationType == 3 && world.miscEntityActivationRange == 0) + {
+ || (entity.activationType == 2 && world.animalEntityActivationRange == 0) + if ( ( entity.activationType == 3 && config.miscActivationRange == 0 )
+ || (entity.activationType == 1 && world.monsterEntityActivationRange == 0) + || ( entity.activationType == 2 && config.animalActivationRange == 0 )
+ || ( entity.activationType == 1 && config.monsterActivationRange == 0 )
+ || entity instanceof EntityHuman + || entity instanceof EntityHuman
+ || entity instanceof EntityProjectile + || entity instanceof EntityProjectile
+ || entity instanceof EntityEnderDragon + || entity instanceof EntityEnderDragon
@ -303,7 +247,8 @@ index e5004b3..2fc33f8 100644
+ || entity instanceof EntityWeather + || entity instanceof EntityWeather
+ || entity instanceof EntityTNTPrimed + || entity instanceof EntityTNTPrimed
+ || entity instanceof EntityEnderCrystal + || entity instanceof EntityEnderCrystal
+ || entity instanceof EntityFireworks) { + || entity instanceof EntityFireworks )
+ {
+ return true; + return true;
+ } + }
+ +
@ -320,7 +265,8 @@ index e5004b3..2fc33f8 100644
+ * @param y + * @param y
+ * @param z + * @param z
+ */ + */
+ public static void growBB(AxisAlignedBB target, AxisAlignedBB source, int x, int y, int z) { + public static void growBB(AxisAlignedBB target, AxisAlignedBB source, int x, int y, int z)
+ {
+ target.a = source.a - x; + target.a = source.a - x;
+ target.b = source.b - y; + target.b = source.b - y;
+ target.c = source.c - z; + target.c = source.c - z;
@ -335,33 +281,38 @@ index e5004b3..2fc33f8 100644
+ * + *
+ * @param world + * @param world
+ */ + */
+ public static void activateEntities(World world) { + public static void activateEntities(World world)
+ {
+ SpigotTimings.entityActivationCheckTimer.startTiming(); + SpigotTimings.entityActivationCheckTimer.startTiming();
+ final int miscActivationRange = world.getWorld().miscEntityActivationRange; + final int miscActivationRange = world.spigotConfig.miscActivationRange;
+ final int animalActivationRange = world.getWorld().animalEntityActivationRange; + final int animalActivationRange = world.spigotConfig.animalActivationRange;
+ final int monsterActivationRange = world.getWorld().monsterEntityActivationRange; + final int monsterActivationRange = world.spigotConfig.monsterActivationRange;
+ +
+ int maxRange = Math.max(monsterActivationRange, animalActivationRange); + int maxRange = Math.max( monsterActivationRange, animalActivationRange );
+ maxRange = Math.max(maxRange, miscActivationRange); + maxRange = Math.max( maxRange, miscActivationRange );
+ maxRange = Math.min((world.getWorld().viewDistance << 4) - 8, maxRange); + maxRange = Math.min( ( world.spigotConfig.viewDistance << 4 ) - 8, maxRange );
+ +
+ for (Entity player : new ArrayList<Entity>(world.players)) { + for ( Entity player : new ArrayList<Entity>( world.players ) )
+ {
+ +
+ player.activatedTick = MinecraftServer.currentTick; + player.activatedTick = MinecraftServer.currentTick;
+ growBB(maxBB, player.boundingBox, maxRange, 256, maxRange); + growBB( maxBB, player.boundingBox, maxRange, 256, maxRange );
+ growBB(miscBB, player.boundingBox, miscActivationRange, 256, miscActivationRange); + growBB( miscBB, player.boundingBox, miscActivationRange, 256, miscActivationRange );
+ growBB(animalBB, player.boundingBox, animalActivationRange, 256, animalActivationRange); + growBB( animalBB, player.boundingBox, animalActivationRange, 256, animalActivationRange );
+ growBB(monsterBB, player.boundingBox, monsterActivationRange, 256, monsterActivationRange); + growBB( monsterBB, player.boundingBox, monsterActivationRange, 256, monsterActivationRange );
+ +
+ int i = MathHelper.floor(maxBB.a / 16.0D); + int i = MathHelper.floor( maxBB.a / 16.0D );
+ int j = MathHelper.floor(maxBB.d / 16.0D); + int j = MathHelper.floor( maxBB.d / 16.0D );
+ int k = MathHelper.floor(maxBB.c / 16.0D); + int k = MathHelper.floor( maxBB.c / 16.0D );
+ int l = MathHelper.floor(maxBB.f / 16.0D); + int l = MathHelper.floor( maxBB.f / 16.0D );
+ +
+ for (int i1 = i; i1 <= j; ++i1) { + for ( int i1 = i; i1 <= j; ++i1 )
+ for (int j1 = k; j1 <= l; ++j1) { + {
+ if (world.getWorld().isChunkLoaded(i1, j1)) { + for ( int j1 = k; j1 <= l; ++j1 )
+ activateChunkEntities(world.getChunkAt(i1, j1)); + {
+ if ( world.getWorld().isChunkLoaded( i1, j1 ) )
+ {
+ activateChunkEntities( world.getChunkAt( i1, j1 ) );
+ } + }
+ } + }
+ } + }
@ -374,28 +325,37 @@ index e5004b3..2fc33f8 100644
+ * + *
+ * @param chunk + * @param chunk
+ */ + */
+ private static void activateChunkEntities(Chunk chunk) { + private static void activateChunkEntities(Chunk chunk)
+ for (List<Entity> slice : chunk.entitySlices) { + {
+ for (Entity entity : slice) { + for ( List<Entity> slice : chunk.entitySlices )
+ if (MinecraftServer.currentTick > entity.activatedTick) { + {
+ if (entity.defaultActivationState) { + for ( Entity entity : slice )
+ {
+ if ( MinecraftServer.currentTick > entity.activatedTick )
+ {
+ if ( entity.defaultActivationState )
+ {
+ entity.activatedTick = MinecraftServer.currentTick; + entity.activatedTick = MinecraftServer.currentTick;
+ continue; + continue;
+ } + }
+ switch (entity.activationType) { + switch ( entity.activationType )
+ {
+ case 1: + case 1:
+ if (monsterBB.a(entity.boundingBox)) { + if ( monsterBB.a( entity.boundingBox ) )
+ {
+ entity.activatedTick = MinecraftServer.currentTick; + entity.activatedTick = MinecraftServer.currentTick;
+ } + }
+ break; + break;
+ case 2: + case 2:
+ if (animalBB.a(entity.boundingBox)) { + if ( animalBB.a( entity.boundingBox ) )
+ {
+ entity.activatedTick = MinecraftServer.currentTick; + entity.activatedTick = MinecraftServer.currentTick;
+ } + }
+ break; + break;
+ case 3: + case 3:
+ default: + default:
+ if (miscBB.a(entity.boundingBox)) { + if ( miscBB.a( entity.boundingBox ) )
+ {
+ entity.activatedTick = MinecraftServer.currentTick; + entity.activatedTick = MinecraftServer.currentTick;
+ } + }
+ } + }
@ -411,37 +371,49 @@ index e5004b3..2fc33f8 100644
+ * @param entity + * @param entity
+ * @return + * @return
+ */ + */
+ public static boolean checkEntityImmunities(Entity entity) { + public static boolean checkEntityImmunities(Entity entity)
+ {
+ // quick checks. + // quick checks.
+ if (entity.inWater /* isInWater */ || entity.fireTicks > 0) { + if ( entity.inWater /* isInWater */ || entity.fireTicks > 0 )
+ {
+ return true; + return true;
+ } + }
+ if (!(entity instanceof EntityArrow)) { + if ( !( entity instanceof EntityArrow ) )
+ if (!entity.onGround || entity.passenger != null + {
+ || entity.vehicle != null) { + if ( !entity.onGround || entity.passenger != null
+ || entity.vehicle != null )
+ {
+ return true; + return true;
+ } + }
+ } else if (!((EntityArrow) entity).inGround) { + } else if ( !( (EntityArrow) entity ).inGround )
+ {
+ return true; + return true;
+ } + }
+ // special cases. + // special cases.
+ if (entity instanceof EntityLiving) { + if ( entity instanceof EntityLiving )
+ {
+ EntityLiving living = (EntityLiving) entity; + EntityLiving living = (EntityLiving) entity;
+ if (living.attackTicks > 0 || living.hurtTicks > 0 || living.effects.size() > 0) { + if ( living.attackTicks > 0 || living.hurtTicks > 0 || living.effects.size() > 0 )
+ {
+ return true; + return true;
+ } + }
+ if (entity instanceof EntityCreature && ((EntityCreature) entity).target != null) { + if ( entity instanceof EntityCreature && ( (EntityCreature) entity ).target != null )
+ {
+ return true; + return true;
+ } + }
+ if (entity instanceof EntityVillager && ((EntityVillager) entity).n()) { + if ( entity instanceof EntityVillager && ( (EntityVillager) entity ).n() )
+ {
+ return true; + return true;
+ } + }
+ if (entity instanceof EntityAnimal) { + if ( entity instanceof EntityAnimal )
+ {
+ EntityAnimal animal = (EntityAnimal) entity; + EntityAnimal animal = (EntityAnimal) entity;
+ if (animal.isBaby() || animal.r() /*love*/) { + if ( animal.isBaby() || animal.r() /*love*/ )
+ {
+ return true; + return true;
+ } + }
+ if (entity instanceof EntitySheep && ((EntitySheep) entity).isSheared()) { + if ( entity instanceof EntitySheep && ( (EntitySheep) entity ).isSheared() )
+ {
+ return true; + return true;
+ } + }
+ } + }
@ -455,63 +427,60 @@ index e5004b3..2fc33f8 100644
+ * @param entity + * @param entity
+ * @return + * @return
+ */ + */
+ public static boolean checkIfActive(Entity entity) { + public static boolean checkIfActive(Entity entity)
+ {
+ SpigotTimings.checkIfActiveTimer.startTiming(); + SpigotTimings.checkIfActiveTimer.startTiming();
+ boolean isActive = entity.activatedTick >= MinecraftServer.currentTick || entity.defaultActivationState; + boolean isActive = entity.activatedTick >= MinecraftServer.currentTick || entity.defaultActivationState;
+ +
+ // Should this entity tick? + // Should this entity tick?
+ if (!isActive) { + if ( !isActive )
+ if ((MinecraftServer.currentTick - entity.activatedTick - 1) % 20 == 0) { + {
+ if ( ( MinecraftServer.currentTick - entity.activatedTick - 1 ) % 20 == 0 )
+ {
+ // Check immunities every 20 ticks. + // Check immunities every 20 ticks.
+ if (checkEntityImmunities(entity)) { + if ( checkEntityImmunities( entity ) )
+ {
+ // Triggered some sort of immunity, give 20 full ticks before we check again. + // Triggered some sort of immunity, give 20 full ticks before we check again.
+ entity.activatedTick = MinecraftServer.currentTick + 20; + entity.activatedTick = MinecraftServer.currentTick + 20;
+ } + }
+ isActive = true; + isActive = true;
+ } + }
+ // Add a little performance juice to active entities. Skip 1/4 if not immune. + // Add a little performance juice to active entities. Skip 1/4 if not immune.
+ } else if (!entity.defaultActivationState && entity.ticksLived % 4 == 0 && !checkEntityImmunities(entity)) { + } else if ( !entity.defaultActivationState && entity.ticksLived % 4 == 0 && !checkEntityImmunities( entity ) )
+ {
+ isActive = false; + isActive = false;
+ } + }
+ int x = MathHelper.floor(entity.locX); + int x = MathHelper.floor( entity.locX );
+ int z = MathHelper.floor(entity.locZ); + int z = MathHelper.floor( entity.locZ );
+ // Make sure not on edge of unloaded chunk + // Make sure not on edge of unloaded chunk
+ if (isActive && !entity.world.areChunksLoaded(x, 0, z, 16)) { + if ( isActive && !entity.world.areChunksLoaded( x, 0, z, 16 ) )
+ {
+ isActive = false; + isActive = false;
+ } + }
+ SpigotTimings.checkIfActiveTimer.stopTiming(); + SpigotTimings.checkIfActiveTimer.stopTiming();
+ return isActive; + return isActive;
+ }
+}
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
index 2f514a0..2824b17 100644
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
@@ -157,4 +157,15 @@ public class SpigotWorldConfig
antiXrayInstance = new AntiXray( this );
} }
public static boolean filterIp(PendingConnection con) {
diff --git a/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java b/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java
index f6e507e..4328ecf 100644
--- a/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java
+++ b/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java
@@ -29,6 +29,9 @@ public class SpigotTimings {
public static final CustomTimingsHandler playerCommandTimer = new CustomTimingsHandler("** playerCommand");
+ public static final CustomTimingsHandler entityActivationCheckTimer = new CustomTimingsHandler("entityActivationCheck");
+ public static final CustomTimingsHandler checkIfActiveTimer = new CustomTimingsHandler("** checkIfActive");
+ +
public static final HashMap<String, CustomTimingsHandler> entityTypeTimingMap = new HashMap<String, CustomTimingsHandler>(); + public int animalActivationRange = 32;
public static final HashMap<String, CustomTimingsHandler> tileEntityTypeTimingMap = new HashMap<String, CustomTimingsHandler>(); + public int monsterActivationRange = 32;
public static final HashMap<String, CustomTimingsHandler> pluginTaskTimingMap = new HashMap<String, CustomTimingsHandler>(); + public int miscActivationRange = 16;
diff --git a/src/main/resources/configurations/bukkit.yml b/src/main/resources/configurations/bukkit.yml + private void activationRange()
index 7860ccc..9c64871 100644 + {
--- a/src/main/resources/configurations/bukkit.yml + animalActivationRange = getInt( "entity-activation-range.animals", animalActivationRange );
+++ b/src/main/resources/configurations/bukkit.yml + monsterActivationRange = getInt( "entity-activation-range.monsters", monsterActivationRange );
@@ -46,6 +46,9 @@ world-settings: + miscActivationRange = getInt( "entity-activation-range.misc", miscActivationRange );
sugar-growth-modifier: 100 + log( "Entity Activation Range: An " + animalActivationRange + " / Mo " + monsterActivationRange + " / Mi " + miscActivationRange );
tree-growth-modifier: 100 + }
mushroom-growth-modifier: 100 }
+ entity-activation-range-animals: 32
+ entity-activation-range-monsters: 32
+ entity-activation-range-misc: 16
info: true
world:
growth-chunks-per-tick: 1000
-- --
1.8.1.2 1.8.1.2