Improve Activation Range by running target rules

This restores monster aggression range back to normal when
Activation Range is less than the monsters aggression range.

This allows an entity to try to acquire targets still during
inactive ticks, which will also then let it go into immunity stage.
This commit is contained in:
Aikar 2018-11-08 22:43:38 -05:00
parent de3b813dcf
commit 2b9a7d9475
No known key found for this signature in database
GPG key ID: 401ADFC9891FAAFE
5 changed files with 98 additions and 26 deletions

View file

@ -1,4 +1,4 @@
From 7ac07ac07ac07ac07ac07ac07ac07ac07ac07ac0 Mon Sep 17 00:00:00 2001
From 138ea64830ff2fd0adfdd094500fea47c1e30852 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Fri, 13 May 2016 01:38:06 -0400
Subject: [PATCH] Activation Range Improvements
@ -10,7 +10,7 @@ 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
index 7ac07ac07ac0..7ac07ac07ac0 100644
index d81e2dc1c5..7bd51b3578 100644
--- a/src/main/java/net/minecraft/server/BlockPosition.java
+++ b/src/main/java/net/minecraft/server/BlockPosition.java
@@ -327,6 +327,7 @@ public class BlockPosition extends BaseBlockPosition {
@ -22,7 +22,7 @@ index 7ac07ac07ac0..7ac07ac07ac0 100644
return new BlockPosition(this);
}
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 7ac07ac07ac0..7ac07ac07ac0 100644
index e7f9e490bf..68ceee5f08 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -575,6 +575,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
@ -34,7 +34,7 @@ index 7ac07ac07ac0..7ac07ac07ac0 100644
if (i != this.aM) {
diff --git a/src/main/java/net/minecraft/server/EntityCreature.java b/src/main/java/net/minecraft/server/EntityCreature.java
index 7ac07ac07ac0..7ac07ac07ac0 100644
index 20b7c2c6dc..d659c57dbe 100644
--- 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;
@ -45,8 +45,30 @@ index 7ac07ac07ac0..7ac07ac07ac0 100644
private BlockPosition a;
private float b;
diff --git a/src/main/java/net/minecraft/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java
index c87304d477..41a4962e94 100644
--- a/src/main/java/net/minecraft/server/EntityInsentient.java
+++ b/src/main/java/net/minecraft/server/EntityInsentient.java
@@ -104,6 +104,17 @@ public abstract class EntityInsentient extends EntityLiving {
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() {
return this.moveController;
}
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index 7ac07ac07ac0..7ac07ac07ac0 100644
index 334580a8b7..b2b575d0e8 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -74,7 +74,7 @@ public abstract class EntityLiving extends Entity {
@ -59,7 +81,7 @@ index 7ac07ac07ac0..7ac07ac07ac0 100644
protected int ticksFarFromPlayer;
protected float aZ;
diff --git a/src/main/java/net/minecraft/server/EntityLlama.java b/src/main/java/net/minecraft/server/EntityLlama.java
index 7ac07ac07ac0..7ac07ac07ac0 100644
index c66d8b68f0..774e4d6414 100644
--- a/src/main/java/net/minecraft/server/EntityLlama.java
+++ b/src/main/java/net/minecraft/server/EntityLlama.java
@@ -340,6 +340,7 @@ public class EntityLlama extends EntityHorseChestedAbstract implements IRangedEn
@ -71,7 +93,7 @@ index 7ac07ac07ac0..7ac07ac07ac0 100644
return this.bQ != null;
}
diff --git a/src/main/java/net/minecraft/server/PathfinderGoal.java b/src/main/java/net/minecraft/server/PathfinderGoal.java
index 7ac07ac07ac0..7ac07ac07ac0 100644
index acc099e955..339c78eec9 100644
--- a/src/main/java/net/minecraft/server/PathfinderGoal.java
+++ b/src/main/java/net/minecraft/server/PathfinderGoal.java
@@ -20,7 +20,9 @@ public abstract class PathfinderGoal {
@ -85,7 +107,7 @@ index 7ac07ac07ac0..7ac07ac07ac0 100644
public void e() {
}
diff --git a/src/main/java/net/minecraft/server/PathfinderGoalGotoTarget.java b/src/main/java/net/minecraft/server/PathfinderGoalGotoTarget.java
index 7ac07ac07ac0..7ac07ac07ac0 100644
index 9a75cb63ba..cf10605aaa 100644
--- a/src/main/java/net/minecraft/server/PathfinderGoalGotoTarget.java
+++ b/src/main/java/net/minecraft/server/PathfinderGoalGotoTarget.java
@@ -1,12 +1,12 @@
@ -125,8 +147,47 @@ index 7ac07ac07ac0..7ac07ac07ac0 100644
return true;
}
}
diff --git a/src/main/java/net/minecraft/server/PathfinderGoalSelector.java b/src/main/java/net/minecraft/server/PathfinderGoalSelector.java
index be3a3c82ee..1404b629d5 100644
--- a/src/main/java/net/minecraft/server/PathfinderGoalSelector.java
+++ b/src/main/java/net/minecraft/server/PathfinderGoalSelector.java
@@ -10,10 +10,10 @@ import org.apache.logging.log4j.Logger;
public class PathfinderGoalSelector {
private static final Logger a = LogManager.getLogger();
private final Set<PathfinderGoalSelector.PathfinderGoalSelectorItem> b = Sets.newLinkedHashSet();
- private final Set<PathfinderGoalSelector.PathfinderGoalSelectorItem> c = Sets.newLinkedHashSet();
+ private final Set<PathfinderGoalSelector.PathfinderGoalSelectorItem> c = Sets.newLinkedHashSet();private Set<PathfinderGoalSelector.PathfinderGoalSelectorItem> getExecutingTasks() { return c; }// Paper - OBFHELPER
private final MethodProfiler d;
- private int e;
- private int f = 3;
+ private int e;private int getCurRate() { return e; } private void incRate() { this.e++; }// Paper - OBFHELPER
+ private int f = 3;private int getTickRate() { return f; } // Paper - OBFHELPER
private int g;
public PathfinderGoalSelector(MethodProfiler methodprofiler) {
@@ -24,6 +24,20 @@ public class PathfinderGoalSelector {
this.b.add(new PathfinderGoalSelector.PathfinderGoalSelectorItem(i, pathfindergoal));
}
+ // Paper start
+ public boolean inactiveTick() {
+ if (getCurRate() % getTickRate() != 0) {
+ incRate();
+ return false;
+ } else {
+ return true;
+ }
+ }
+ public boolean hasTasks() {
+ return !getExecutingTasks().isEmpty();
+ }
+ // Paper end
+
public void a(PathfinderGoal pathfindergoal) {
Iterator iterator = this.b.iterator();
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
index 7ac07ac07ac0..7ac07ac07ac0 100644
index 09df00e94b..d08ef3fe10 100644
--- a/src/main/java/org/spigotmc/ActivationRange.java
+++ b/src/main/java/org/spigotmc/ActivationRange.java
@@ -2,6 +2,8 @@ package org.spigotmc;
@ -298,7 +359,18 @@ index 7ac07ac07ac0..7ac07ac07ac0 100644
if ( entity instanceof EntityAnimal )
{
EntityAnimal animal = (EntityAnimal) entity;
@@ -274,10 +311,10 @@ public class ActivationRange
@@ -268,16 +305,20 @@ public class ActivationRange
entity.activatedTick = MinecraftServer.currentTick + 20;
}
isActive = true;
+ // Paper start
+ } else if (entity instanceof EntityInsentient && ((EntityInsentient) entity).targetSelector.hasTasks()) {
+ isActive = true;
}
+ // Paper end
// 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 && !(entity instanceof EntityInsentient && ((EntityInsentient) entity).targetSelector.hasTasks()) && !checkEntityImmunities( entity ) ) // Paper - add targetSelector.hasTasks
{
isActive = false;
}
@ -313,7 +385,7 @@ index 7ac07ac07ac0..7ac07ac07ac0 100644
{
isActive = false;
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
index 7ac07ac07ac0..7ac07ac07ac0 100644
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

View file

@ -1,4 +1,4 @@
From f74f5f78131c69430ee9281954378ee943a085a2 Mon Sep 17 00:00:00 2001
From ed99479d1b81272b059aa5e8b102a4dae3a0ebb4 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 18 Jun 2016 23:22:12 -0400
Subject: [PATCH] Delay Chunk Unloads based on Player Movement
@ -211,10 +211,10 @@ index 24e504c279..f0e974dffc 100644
}
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
index dfa59bbddc..8f0a999b0c 100644
index d08ef3fe10..081789a8fe 100644
--- a/src/main/java/org/spigotmc/ActivationRange.java
+++ b/src/main/java/org/spigotmc/ActivationRange.java
@@ -319,6 +319,11 @@ public class ActivationRange
@@ -323,6 +323,11 @@ public class ActivationRange
{
isActive = false;
}

View file

@ -1,14 +1,14 @@
From 1c7be2d6340c5d04e4ad3990cee743353727952e Mon Sep 17 00:00:00 2001
From 1ab48f50256eaea71822fe4b181bfbb22bbb7f72 Mon Sep 17 00:00:00 2001
From: BillyGalbreath <Blake.Galbreath@GMail.com>
Date: Fri, 5 May 2017 03:57:17 -0500
Subject: [PATCH] Item#canEntityPickup
diff --git a/src/main/java/net/minecraft/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java
index 6f5f3f8cd0..04a1218ed9 100644
index 41a4962e94..200d46a8a0 100644
--- a/src/main/java/net/minecraft/server/EntityInsentient.java
+++ b/src/main/java/net/minecraft/server/EntityInsentient.java
@@ -518,6 +518,11 @@ public abstract class EntityInsentient extends EntityLiving {
@@ -529,6 +529,11 @@ public abstract class EntityInsentient extends EntityLiving {
EntityItem entityitem = (EntityItem) iterator.next();
if (!entityitem.dead && !entityitem.getItemStack().isEmpty() && !entityitem.q()) {
@ -21,7 +21,7 @@ index 6f5f3f8cd0..04a1218ed9 100644
}
}
diff --git a/src/main/java/net/minecraft/server/EntityItem.java b/src/main/java/net/minecraft/server/EntityItem.java
index eecebafdad..3e70a06397 100644
index 5be2d93146..5446ff3e82 100644
--- a/src/main/java/net/minecraft/server/EntityItem.java
+++ b/src/main/java/net/minecraft/server/EntityItem.java
@@ -13,6 +13,7 @@ public class EntityItem extends Entity {
@ -54,5 +54,5 @@ index a17a537d69..1df17f09bb 100644
public String toString() {
return "CraftItem";
--
2.19.0
2.19.1

View file

@ -1,4 +1,4 @@
From 7ebee1455ff20e7424264ecce40e8dd4c8de973c Mon Sep 17 00:00:00 2001
From 085ab94bffa4a3c2d94334a64b83e5af05902981 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Thu, 19 Jul 2018 01:23:00 -0400
Subject: [PATCH] Don't process despawn if entity is in a chunk scheduled for
@ -12,10 +12,10 @@ keep it vanilla in behavior
a player may teleport away, and trigger instant despawn
diff --git a/src/main/java/net/minecraft/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java
index 04a1218ed9..141db48f16 100644
index 200d46a8a0..db9201d292 100644
--- a/src/main/java/net/minecraft/server/EntityInsentient.java
+++ b/src/main/java/net/minecraft/server/EntityInsentient.java
@@ -623,6 +623,8 @@ public abstract class EntityInsentient extends EntityLiving {
@@ -634,6 +634,8 @@ public abstract class EntityInsentient extends EntityLiving {
if (this.persistent) {
this.ticksFarFromPlayer = 0;
} else {
@ -25,5 +25,5 @@ index 04a1218ed9..141db48f16 100644
if (entityhuman != null && entityhuman.affectsSpawning) { // Paper - Affects Spawning API
--
2.19.0
2.19.1

View file

@ -1,14 +1,14 @@
From 4c9116f3e592f2ce2708d593e0379be42d0a43fc Mon Sep 17 00:00:00 2001
From d95fe94f2eaa0f9bb2be771c4005d63dcd2b9406 Mon Sep 17 00:00:00 2001
From: BillyGalbreath <Blake.Galbreath@GMail.com>
Date: Sun, 7 Oct 2018 00:54:21 -0500
Subject: [PATCH] Add sun related API
diff --git a/src/main/java/net/minecraft/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java
index 5aea6629f2..fd4a77c1a9 100644
index db9201d292..6c9776f57e 100644
--- a/src/main/java/net/minecraft/server/EntityInsentient.java
+++ b/src/main/java/net/minecraft/server/EntityInsentient.java
@@ -1286,6 +1286,7 @@ public abstract class EntityInsentient extends EntityLiving {
@@ -1297,6 +1297,7 @@ public abstract class EntityInsentient extends EntityLiving {
return flag;
}