Entity Activation Range

This feature gives 3 new configurable ranges that if an entity of the matching type is outside of this radius of any player, will tick at 5% of its normal rate.

This will drastically cut down on tick timings for entities that are not in range of a user to actually be "used".
This change can have dramatic impact on gameplay if configured too low. Balance according to your servers desired gameplay.

By: Aikar <aikar@aikar.co>
This commit is contained in:
CraftBukkit/Spigot
2024-11-02 18:16:11 +11:00
parent 54a84c6c79
commit 28c8009a16
12 changed files with 730 additions and 262 deletions

View File

@@ -22,7 +22,27 @@
@Nullable
public UUID ownerUUID;
@@ -200,7 +206,7 @@
@@ -145,7 +151,19 @@
this.duration = duration;
}
+ // Spigot start - copied from below
@Override
+ public void inactiveTick() {
+ super.inactiveTick();
+
+ if (this.tickCount >= this.waitTime + this.duration) {
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
+ return;
+ }
+ }
+ // Spigot end
+
+ @Override
public void tick() {
super.tick();
Level world = this.level();
@@ -200,7 +218,7 @@
private void serverTick(ServerLevel world) {
if (this.tickCount >= this.waitTime + this.duration) {
@@ -31,7 +51,7 @@
} else {
boolean flag = this.isWaiting();
boolean flag1 = this.tickCount < this.waitTime;
@@ -215,7 +221,7 @@
@@ -215,7 +233,7 @@
if (this.radiusPerTick != 0.0F) {
f += this.radiusPerTick;
if (f < 0.5F) {
@@ -40,7 +60,7 @@
return;
}
@@ -244,16 +250,17 @@
@@ -244,16 +262,17 @@
}
list.addAll(this.potionContents.customEffects());
@@ -61,7 +81,7 @@
Objects.requireNonNull(entityliving);
if (!stream.noneMatch(entityliving::canBeAffected)) {
@@ -262,6 +269,19 @@
@@ -262,6 +281,19 @@
double d2 = d0 * d0 + d1 * d1;
if (d2 <= (double) (f * f)) {
@@ -81,7 +101,7 @@
this.victims.put(entityliving, this.tickCount + this.reapplicationDelay);
Iterator iterator2 = list.iterator();
@@ -271,14 +291,14 @@
@@ -271,14 +303,14 @@
if (((MobEffect) mobeffect1.getEffect().value()).isInstantenous()) {
((MobEffect) mobeffect1.getEffect().value()).applyInstantenousEffect(world, this, this.getOwner(), entityliving, mobeffect1.getAmplifier(), 0.5D);
} else {
@@ -98,7 +118,7 @@
return;
}
@@ -288,7 +308,7 @@
@@ -288,7 +320,7 @@
if (this.durationOnUse != 0) {
this.duration += this.durationOnUse;
if (this.duration <= 0) {
@@ -107,7 +127,7 @@
return;
}
}
@@ -336,14 +356,14 @@
@@ -336,14 +368,14 @@
this.waitTime = waitTime;
}
@@ -124,7 +144,7 @@
if (this.owner != null && !this.owner.isRemoved()) {
return this.owner;
} else {
@@ -353,10 +373,10 @@
@@ -353,10 +385,10 @@
if (world instanceof ServerLevel) {
ServerLevel worldserver = (ServerLevel) world;
Entity entity = worldserver.getEntity(this.ownerUUID);