2020-04-21 22:06:30 +00:00
From b7cf9daeb3a69c939ac70de4b8caa88f657b88b1 Mon Sep 17 00:00:00 2001
2020-01-20 15:54:57 +00:00
From: Aikar <aikar@aikar.co>
Date: Fri, 13 May 2016 01:38:06 -0400
Subject: [PATCH] Activation Range Improvements
Optimizes performance of Activation Range
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/Entity.java b/src/main/java/net/minecraft/server/Entity.java
2020-04-12 06:41:57 +00:00
index 0900db05..6509463e 100644
2020-01-20 15:54:57 +00:00
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
2020-03-30 02:26:44 +00:00
@@ -192,6 +192,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
public final org.spigotmc.ActivationRange.ActivationType activationType = org.spigotmc.ActivationRange.initializeEntityActivationType(this);
public final boolean defaultActivationState;
public long activatedTick = Integer.MIN_VALUE;
+ public boolean isTemporarilyActive = false; // Paper
public boolean spawnedViaMobSpawner; // Paper - Yes this name is similar to above, upstream took the better one
protected int numCollisions = 0; // Paper
public void inactiveTick() { }
@@ -553,6 +554,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
2020-01-20 15:54:57 +00:00
this.recalcPosition();
} else {
if (enummovetype == EnumMoveType.PISTON) {
+ this.activatedTick = MinecraftServer.currentTick + 20; // Paper
vec3d = this.a(vec3d);
if (vec3d.equals(Vec3D.a)) {
return;
2020-04-12 06:41:57 +00:00
@@ -565,6 +567,13 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
2020-04-02 05:25:36 +00:00
this.y = Vec3D.a;
this.setMot(Vec3D.a);
}
+ // Paper start - ignore movement changes while inactive.
2020-04-03 03:12:21 +00:00
+ if (isTemporarilyActive && !(this instanceof EntityItem) && vec3d == getMot() && enummovetype == EnumMoveType.SELF) {
2020-04-02 05:25:36 +00:00
+ setMot(Vec3D.a);
2020-04-12 06:41:57 +00:00
+ this.world.getMethodProfiler().exit();
2020-04-02 05:25:36 +00:00
+ return;
+ }
+ // Paper end
vec3d = this.a(vec3d, enummovetype);
Vec3D vec3d1 = this.e(vec3d);
2020-04-12 06:41:57 +00:00
@@ -2765,6 +2774,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
2020-04-02 05:25:36 +00:00
return this.am;
}
+ public boolean isPushedByWater() { return this.bM(); } // Paper - OBFHELPER - the below is not an obfhelper, don't use it!
public boolean bM() {
// Paper start
return this.pushedByWater();
2020-01-20 15:54:57 +00:00
diff --git a/src/main/java/net/minecraft/server/EntityCreature.java b/src/main/java/net/minecraft/server/EntityCreature.java
2020-04-12 06:41:57 +00:00
index b40c8d2f..4eda1307 100644
2020-01-20 15:54:57 +00:00
--- a/src/main/java/net/minecraft/server/EntityCreature.java
+++ b/src/main/java/net/minecraft/server/EntityCreature.java
@@ -7,6 +7,7 @@ import org.bukkit.event.entity.EntityUnleashEvent;
public abstract class EntityCreature extends EntityInsentient {
public org.bukkit.craftbukkit.entity.CraftCreature getBukkitCreature() { return (org.bukkit.craftbukkit.entity.CraftCreature) super.getBukkitEntity(); } // Paper
+ public BlockPosition movingTarget = null; public BlockPosition getMovingTarget() { return movingTarget; } // Paper
protected EntityCreature(EntityTypes<? extends EntityCreature> entitytypes, World world) {
super(entitytypes, world);
diff --git a/src/main/java/net/minecraft/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java
2020-04-12 06:41:57 +00:00
index 6d53254f..1991cee4 100644
2020-01-20 15:54:57 +00:00
--- a/src/main/java/net/minecraft/server/EntityInsentient.java
+++ b/src/main/java/net/minecraft/server/EntityInsentient.java
2020-02-21 17:52:20 +00:00
@@ -114,6 +114,17 @@ public abstract class EntityInsentient extends EntityLiving {
2020-01-20 15:54:57 +00:00
return this.lookController;
}
+ // Paper start
+ @Override
+ public void inactiveTick() {
+ super.inactiveTick();
+ this.goalSelector.inactiveTick();
+ if (this.targetSelector.inactiveTick()) {
+ this.targetSelector.doTick();
+ }
+ }
+ // Paper end
+
public ControllerMove getControllerMove() {
if (this.isPassenger() && this.getVehicle() instanceof EntityInsentient) {
EntityInsentient entityinsentient = (EntityInsentient) this.getVehicle();
diff --git a/src/main/java/net/minecraft/server/EntityLlama.java b/src/main/java/net/minecraft/server/EntityLlama.java
2020-04-12 06:41:57 +00:00
index 6d4d41c8..193dbfc5 100644
2020-01-20 15:54:57 +00:00
--- a/src/main/java/net/minecraft/server/EntityLlama.java
+++ b/src/main/java/net/minecraft/server/EntityLlama.java
@@ -382,6 +382,7 @@ public class EntityLlama extends EntityHorseChestedAbstract implements IRangedEn
return this.bK != null;
}
+ public boolean inCaravan() { return this.fd(); } // Paper - OBFHELPER
public boolean fd() {
return this.bJ != null;
}
diff --git a/src/main/java/net/minecraft/server/PathfinderGoal.java b/src/main/java/net/minecraft/server/PathfinderGoal.java
2020-04-12 06:41:57 +00:00
index f22f12ee..bdb90a34 100644
2020-01-20 15:54:57 +00:00
--- a/src/main/java/net/minecraft/server/PathfinderGoal.java
+++ b/src/main/java/net/minecraft/server/PathfinderGoal.java
@@ -20,7 +20,10 @@ public abstract class PathfinderGoal {
public void c() {}
- public void d() {}
+ public void d() {
+ onTaskReset(); // Paper
+ }
+ public void onTaskReset() {} // Paper
public void e() {}
diff --git a/src/main/java/net/minecraft/server/PathfinderGoalGotoTarget.java b/src/main/java/net/minecraft/server/PathfinderGoalGotoTarget.java
2020-04-12 06:41:57 +00:00
index 41fb166c..e93129f0 100644
2020-01-20 15:54:57 +00:00
--- a/src/main/java/net/minecraft/server/PathfinderGoalGotoTarget.java
+++ b/src/main/java/net/minecraft/server/PathfinderGoalGotoTarget.java
@@ -4,12 +4,12 @@ import java.util.EnumSet;
public abstract class PathfinderGoalGotoTarget extends PathfinderGoal {
- protected final EntityCreature a;
+ protected final EntityCreature a;public EntityCreature getEntity() { return a; } // Paper - OBFHELPER
public final double b;
protected int c;
protected int d;
private int g;
- protected BlockPosition e;
+ protected BlockPosition e; public BlockPosition getTarget() { return e; } public void setTarget(BlockPosition pos) { this.e = pos; getEntity().movingTarget = pos != BlockPosition.ZERO ? pos : null; } // Paper - OBFHELPER
private boolean h;
private final int i;
private final int j;
@@ -18,6 +18,13 @@ public abstract class PathfinderGoalGotoTarget extends PathfinderGoal {
public PathfinderGoalGotoTarget(EntityCreature entitycreature, double d0, int i) {
this(entitycreature, d0, i, 1);
}
+ // Paper start - activation range improvements
+ @Override
+ public void onTaskReset() {
+ super.onTaskReset();
+ setTarget(BlockPosition.ZERO);
+ }
+ // Paper end
public PathfinderGoalGotoTarget(EntityCreature entitycreature, double d0, int i, int j) {
this.e = BlockPosition.ZERO;
@@ -100,6 +107,7 @@ public abstract class PathfinderGoalGotoTarget extends PathfinderGoal {
blockposition_mutableblockposition.g(blockposition).e(i1, k - 1, j1);
if (this.a.a((BlockPosition) blockposition_mutableblockposition) && this.a(this.a.world, blockposition_mutableblockposition)) {
this.e = blockposition_mutableblockposition;
+ setTarget(blockposition_mutableblockposition.immutableCopy()); // Paper
return true;
}
}
diff --git a/src/main/java/net/minecraft/server/PathfinderGoalSelector.java b/src/main/java/net/minecraft/server/PathfinderGoalSelector.java
2020-04-12 06:41:57 +00:00
index 44bb18c5..93513677 100644
2020-01-20 15:54:57 +00:00
--- a/src/main/java/net/minecraft/server/PathfinderGoalSelector.java
+++ b/src/main/java/net/minecraft/server/PathfinderGoalSelector.java
@@ -24,10 +24,11 @@ public class PathfinderGoalSelector {
}
};
private final Map<PathfinderGoal.Type, PathfinderGoalWrapped> c = new EnumMap(PathfinderGoal.Type.class);
- private final Set<PathfinderGoalWrapped> d = Sets.newLinkedHashSet();
2020-01-26 23:35:34 +00:00
+ private final Set<PathfinderGoalWrapped> d = Sets.newLinkedHashSet();private Set<PathfinderGoalWrapped> getTasks() { return d; }// Paper - OBFHELPER
2020-01-20 15:54:57 +00:00
private final GameProfilerFiller e;
private final EnumSet<PathfinderGoal.Type> f = EnumSet.noneOf(PathfinderGoal.Type.class);
- private int g = 3;
+ private int g = 3;private int getTickRate() { return g; } // Paper - OBFHELPER
+ private int curRate;private int getCurRate() { return curRate; } private void incRate() { this.curRate++; } // Paper TODO
public PathfinderGoalSelector(GameProfilerFiller gameprofilerfiller) {
this.e = gameprofilerfiller;
2020-01-26 23:35:34 +00:00
@@ -37,6 +38,25 @@ public class PathfinderGoalSelector {
2020-01-20 15:54:57 +00:00
this.d.add(new PathfinderGoalWrapped(i, pathfindergoal));
}
+ // Paper start
+ public boolean inactiveTick() {
+ if (getCurRate() % getTickRate() != 0) {
+ incRate();
+ return false;
+ } else {
+ return true;
+ }
+ }
+ public boolean hasTasks() {
2020-01-26 23:35:34 +00:00
+ for (PathfinderGoalWrapped task : getTasks()) {
+ if (task.isRunning()) {
+ return true;
+ }
+ }
+ return false;
2020-01-20 15:54:57 +00:00
+ }
+ // Paper end
+
public void a(PathfinderGoal pathfindergoal) {
this.d.stream().filter((pathfindergoalwrapped) -> {
return pathfindergoalwrapped.j() == pathfindergoal;
2020-01-26 23:35:34 +00:00
diff --git a/src/main/java/net/minecraft/server/PathfinderGoalWrapped.java b/src/main/java/net/minecraft/server/PathfinderGoalWrapped.java
2020-04-12 06:41:57 +00:00
index 5a8c60ad..29657fed 100644
2020-01-26 23:35:34 +00:00
--- a/src/main/java/net/minecraft/server/PathfinderGoalWrapped.java
+++ b/src/main/java/net/minecraft/server/PathfinderGoalWrapped.java
@@ -64,6 +64,7 @@ public class PathfinderGoalWrapped extends PathfinderGoal {
return this.a.i();
}
+ public boolean isRunning() { return this.g(); } // Paper - OBFHELPER
public boolean g() {
return this.c;
}
2020-01-20 15:54:57 +00:00
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
2020-04-12 06:41:57 +00:00
index 92601c58..79581717 100644
2020-01-20 15:54:57 +00:00
--- a/src/main/java/org/spigotmc/ActivationRange.java
+++ b/src/main/java/org/spigotmc/ActivationRange.java
2020-04-02 05:25:36 +00:00
@@ -3,11 +3,15 @@ package org.spigotmc;
2020-03-30 02:26:44 +00:00
import java.util.Collection;
import java.util.List;
import net.minecraft.server.AxisAlignedBB;
+import net.minecraft.server.BehaviorController;
2020-04-02 05:25:36 +00:00
+import net.minecraft.server.BlockPosition;
2020-03-30 02:26:44 +00:00
import net.minecraft.server.Chunk;
2020-03-30 02:41:33 +00:00
+import net.minecraft.server.ChunkProviderServer; // Paper
2020-03-30 02:26:44 +00:00
import net.minecraft.server.Entity;
import net.minecraft.server.EntityAmbient;
2020-03-30 02:41:33 +00:00
import net.minecraft.server.EntityAnimal;
2020-04-02 05:25:36 +00:00
import net.minecraft.server.EntityArrow;
+import net.minecraft.server.EntityBee;
import net.minecraft.server.EntityComplexPart;
import net.minecraft.server.EntityCreature;
import net.minecraft.server.EntityCreeper;
@@ -16,10 +20,13 @@ import net.minecraft.server.EntityEnderDragon;
2020-03-30 02:26:44 +00:00
import net.minecraft.server.EntityFallingBlock; // Paper
import net.minecraft.server.EntityFireball;
import net.minecraft.server.EntityFireworks;
+import net.minecraft.server.EntityFlying;
import net.minecraft.server.EntityHuman;
import net.minecraft.server.EntityLightning;
import net.minecraft.server.EntityLiving;
import net.minecraft.server.EntityMonster;
2020-04-02 05:25:36 +00:00
+import net.minecraft.server.EntityPillager;
2020-03-30 02:26:44 +00:00
+import net.minecraft.server.EntityPlayer;
import net.minecraft.server.EntityProjectile;
import net.minecraft.server.EntityRaider;
import net.minecraft.server.EntitySheep;
2020-04-02 05:25:36 +00:00
@@ -30,15 +37,22 @@ import net.minecraft.server.EntityThrownTrident;
2020-03-30 02:26:44 +00:00
import net.minecraft.server.EntityVillager;
import net.minecraft.server.EntityWither;
import net.minecraft.server.MathHelper;
+import net.minecraft.server.MemoryModuleType;
2020-01-20 15:54:57 +00:00
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.World;
import co.aikar.timings.MinecraftTimings;
+// Paper start
+import net.minecraft.server.EntityInsentient;
+import net.minecraft.server.EntityLlama;
+import net.minecraft.server.EntityWaterAnimal;
+// Paper end
public class ActivationRange
{
public enum ActivationType
{
+ WATER, // Paper
MONSTER,
ANIMAL,
RAIDER,
2020-04-02 05:25:36 +00:00
@@ -58,6 +72,7 @@ public class ActivationRange
2020-01-20 15:54:57 +00:00
*/
public static ActivationType initializeEntityActivationType(Entity entity)
{
+ if (entity instanceof EntityWaterAnimal) { return ActivationType.WATER; } // Paper
if ( entity instanceof EntityRaider )
{
return ActivationType.RAIDER;
2020-04-02 05:25:36 +00:00
@@ -86,6 +101,7 @@ public class ActivationRange
2020-01-20 15:54:57 +00:00
|| ( entity.activationType == ActivationType.RAIDER && config.raiderActivationRange == 0 )
|| ( entity.activationType == ActivationType.ANIMAL && config.animalActivationRange == 0 )
|| ( entity.activationType == ActivationType.MONSTER && config.monsterActivationRange == 0 )
+ || ( entity.activationType == ActivationType.WATER && config.waterActivationRange == 0 ) // Paper
|| entity instanceof EntityHuman
|| entity instanceof EntityProjectile
|| entity instanceof EntityEnderDragon
2020-04-02 05:25:36 +00:00
@@ -118,6 +134,8 @@ public class ActivationRange
2020-01-20 15:54:57 +00:00
final int raiderActivationRange = world.spigotConfig.raiderActivationRange;
final int animalActivationRange = world.spigotConfig.animalActivationRange;
final int monsterActivationRange = world.spigotConfig.monsterActivationRange;
+ final int waterActivationRange = world.spigotConfig.waterActivationRange; // Paper
2020-03-30 02:41:33 +00:00
+ final ChunkProviderServer chunkProvider = (ChunkProviderServer) world.getChunkProvider(); // Paper
2020-01-20 15:54:57 +00:00
int maxRange = Math.max( monsterActivationRange, animalActivationRange );
maxRange = Math.max( maxRange, raiderActivationRange );
2020-04-02 05:25:36 +00:00
@@ -133,6 +151,8 @@ public class ActivationRange
2020-01-20 15:54:57 +00:00
ActivationType.RAIDER.boundingBox = player.getBoundingBox().grow( raiderActivationRange, 256, raiderActivationRange );
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
+
int i = MathHelper.floor( maxBB.minX / 16.0D );
int j = MathHelper.floor( maxBB.maxX / 16.0D );
2020-04-02 05:25:36 +00:00
@@ -143,7 +163,7 @@ public class ActivationRange
2020-03-30 02:41:33 +00:00
{
for ( int j1 = k; j1 <= l; ++j1 )
{
- Chunk chunk = (Chunk) world.getChunkIfLoadedImmediately( i1, j1 );
+ Chunk chunk = chunkProvider.getChunkAtIfLoadedMainThreadNoCache( i1, j1 ); // Paper
if ( chunk != null )
{
activateChunkEntities( chunk );
2020-04-02 05:25:36 +00:00
@@ -161,19 +181,15 @@ public class ActivationRange
2020-03-30 02:41:33 +00:00
*/
private static void activateChunkEntities(Chunk chunk)
{
- for ( List<Entity> slice : chunk.entitySlices )
- {
- for ( Entity entity : (Collection<Entity>) slice )
+ // Paper start
+ Entity[] rawData = chunk.entities.getRawData();
+ for (int i = 0; i < chunk.entities.size(); i++) {
+ Entity entity = rawData[i];
+ //for ( Entity entity : (Collection<Entity>) slice )
+ // Paper end
{
- if ( MinecraftServer.currentTick > entity.activatedTick )
- {
- if ( entity.defaultActivationState )
- {
- entity.activatedTick = MinecraftServer.currentTick;
- continue;
- }
- if ( entity.activationType.boundingBox.c( entity.getBoundingBox() ) )
- {
+ if (MinecraftServer.currentTick > entity.activatedTick) {
+ if (entity.defaultActivationState || entity.activationType.boundingBox.c(entity.getBoundingBox())) { // Paper
entity.activatedTick = MinecraftServer.currentTick;
}
}
2020-04-02 05:25:36 +00:00
@@ -188,22 +204,22 @@ public class ActivationRange
2020-03-30 02:26:44 +00:00
* @param entity
* @return
*/
- public static boolean checkEntityImmunities(Entity entity)
+ public static int checkEntityImmunities(Entity entity) // Paper - return # of ticks to get immunity
{
// quick checks.
- if ( entity.inWater || entity.fireTicks > 0 )
2020-04-02 05:25:36 +00:00
+ if ( (entity.activationType != ActivationType.WATER && entity.inWater && entity.pushedByWater()) || entity.fireTicks > 0 ) // Paper
2020-03-30 02:26:44 +00:00
{
- return true;
2020-04-03 03:12:21 +00:00
+ return 100; // Paper
2020-03-30 02:26:44 +00:00
}
if ( !( entity instanceof EntityArrow ) )
{
- if ( !entity.onGround || !entity.passengers.isEmpty() || entity.isPassenger() )
+ if ( (!entity.onGround && !(entity instanceof EntityFlying)) || !entity.passengers.isEmpty() || entity.isPassenger() ) // Paper
2020-01-20 15:54:57 +00:00
{
2020-03-30 02:26:44 +00:00
- return true;
+ return 10; // Paper
2020-01-20 15:54:57 +00:00
}
2020-03-30 02:26:44 +00:00
} else if ( !( (EntityArrow) entity ).inGround )
{
- return true;
+ return 1; // Paper
}
// special cases.
if ( entity instanceof EntityLiving )
2020-04-02 05:25:36 +00:00
@@ -211,33 +227,63 @@ public class ActivationRange
2020-03-30 02:26:44 +00:00
EntityLiving living = (EntityLiving) entity;
if ( /*TODO: Missed mapping? living.attackTicks > 0 || */ living.hurtTicks > 0 || living.effects.size() > 0 )
2020-01-20 15:54:57 +00:00
{
2020-03-30 02:26:44 +00:00
- return true;
+ return 1; // Paper
2020-01-20 15:54:57 +00:00
}
2020-03-30 02:26:44 +00:00
- if ( entity instanceof EntityCreature && ( (EntityCreature) entity ).getGoalTarget() != null )
2020-04-02 05:25:36 +00:00
+ if ( entity instanceof EntityInsentient && ((EntityInsentient) entity ).getGoalTarget() != null) // Paper
2020-01-20 15:54:57 +00:00
{
2020-03-30 02:26:44 +00:00
- return true;
+ return 20; // Paper
2020-04-02 05:25:36 +00:00
+ }
2020-03-30 02:26:44 +00:00
+ // Paper start
2020-04-02 05:25:36 +00:00
+ if (entity instanceof EntityBee) {
+ EntityBee bee = (EntityBee)entity;
+ BlockPosition movingTarget = bee.getMovingTarget();
+ if (bee.isAngry() ||
+ (bee.getHivePos() != null && bee.getHivePos().equals(movingTarget)) ||
+ (bee.getFlowerPos() != null && bee.getFlowerPos().equals(movingTarget))
+ ) {
+ return 20;
+ }
}
2020-03-30 02:26:44 +00:00
if ( entity instanceof EntityVillager && ( (EntityVillager) entity ).canBreed() )
{
- return true;
+ BehaviorController<EntityVillager> behaviorController = ((EntityVillager) entity).getBehaviorController();
+ if (behaviorController.hasMemory(MemoryModuleType.BREED_TARGET)) {
+ return 1;
+ }
+ // Paper end
2020-04-02 05:25:36 +00:00
}
2020-01-20 15:54:57 +00:00
+ // Paper start
+ if ( entity instanceof EntityLlama && ( (EntityLlama ) entity ).inCaravan() )
+ {
2020-03-30 02:26:44 +00:00
+ return 0;
2020-04-02 05:25:36 +00:00
+ }
2020-01-20 15:54:57 +00:00
+ // Paper end
if ( entity instanceof EntityAnimal )
{
EntityAnimal animal = (EntityAnimal) entity;
2020-03-30 02:26:44 +00:00
if ( animal.isBaby() || animal.isInLove() )
{
- return true;
+ return 1; // Paper
2020-01-20 15:54:57 +00:00
}
2020-03-30 02:26:44 +00:00
if ( entity instanceof EntitySheep && ( (EntitySheep) entity ).isSheared() )
{
- return true;
+ return 1; // Paper
}
}
if (entity instanceof EntityCreeper && ((EntityCreeper) entity).isIgnited()) { // isExplosive
- return true;
+ return 20; // Paper
2020-04-02 05:25:36 +00:00
+ }
2020-01-20 15:54:57 +00:00
+ // Paper start
2020-03-30 02:26:44 +00:00
+ if (entity instanceof EntityInsentient && ((EntityInsentient) entity).targetSelector.hasTasks() ) {
+ return 0;
2020-04-02 05:25:36 +00:00
}
+ if (entity instanceof EntityPillager) {
+ EntityPillager pillager = (EntityPillager) entity;
+ // TODO:?
2020-03-30 02:41:33 +00:00
+ }
2020-01-20 15:54:57 +00:00
+ // Paper end
2020-03-30 02:26:44 +00:00
}
- return false;
+ return -1; // Paper
}
/**
2020-04-02 05:25:36 +00:00
@@ -254,6 +300,7 @@ public class ActivationRange
2020-03-30 02:26:44 +00:00
}
boolean isActive = entity.activatedTick >= MinecraftServer.currentTick || entity.defaultActivationState;
+ entity.isTemporarilyActive = false; // Paper
// Should this entity tick?
if ( !isActive )
2020-04-02 05:25:36 +00:00
@@ -261,15 +308,19 @@ public class ActivationRange
2020-03-30 02:26:44 +00:00
if ( ( MinecraftServer.currentTick - entity.activatedTick - 1 ) % 20 == 0 )
{
// Check immunities every 20 ticks.
- if ( checkEntityImmunities( entity ) )
- {
- // Triggered some sort of immunity, give 20 full ticks before we check again.
- entity.activatedTick = MinecraftServer.currentTick + 20;
+ // Paper start
+ int immunity = checkEntityImmunities(entity);
+ if (immunity >= 0) {
+ entity.activatedTick = MinecraftServer.currentTick + immunity;
+ } else {
+ entity.isTemporarilyActive = true;
}
+ // Paper end
isActive = true;
+
}
2020-01-20 15:54:57 +00:00
// Add a little performance juice to active entities. Skip 1/4 if not immune.
- } else if ( !entity.defaultActivationState && entity.ticksLived % 4 == 0 && !checkEntityImmunities( entity ) )
2020-03-30 02:26:44 +00:00
+ } else if ( !entity.defaultActivationState && entity.ticksLived % 4 == 0 && checkEntityImmunities( entity) < 0 ) // Paper
2020-01-20 15:54:57 +00:00
{
isActive = false;
}
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
2020-04-12 06:41:57 +00:00
index 5e932a5d..1b42ba94 100644
2020-01-20 15:54:57 +00:00
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
@@ -180,6 +180,7 @@ public class SpigotWorldConfig
public int monsterActivationRange = 32;
public int raiderActivationRange = 48;
public int miscActivationRange = 16;
+ public int waterActivationRange = 16; // Paper
public boolean tickInactiveVillagers = true;
private void activationRange()
{
@@ -187,6 +188,7 @@ public class SpigotWorldConfig
monsterActivationRange = getInt( "entity-activation-range.monsters", monsterActivationRange );
raiderActivationRange = getInt( "entity-activation-range.raiders", raiderActivationRange );
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 + " / Ra " + raiderActivationRange + " / Mi " + miscActivationRange + " / Tiv " + tickInactiveVillagers );
}
--
2020-04-21 22:06:30 +00:00
2.25.1.windows.1
2020-01-20 15:54:57 +00:00