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

@@ -24,7 +24,26 @@
}
@Override
@@ -235,7 +243,7 @@
@@ -216,7 +224,18 @@
return this.assignProfessionWhenSpawned;
}
+ // Spigot Start
@Override
+ public void inactiveTick() {
+ // SPIGOT-3874, SPIGOT-3894, SPIGOT-3846, SPIGOT-5286 :(
+ if (this.level().spigotConfig.tickInactiveVillagers && this.isEffectiveAi()) {
+ this.customServerAiStep((ServerLevel) this.level());
+ }
+ super.inactiveTick();
+ }
+ // Spigot End
+
+ @Override
protected void customServerAiStep(ServerLevel world) {
ProfilerFiller gameprofilerfiller = Profiler.get();
@@ -235,7 +254,7 @@
this.increaseProfessionLevelOnUpdate = false;
}
@@ -33,7 +52,7 @@
}
}
@@ -360,7 +368,13 @@
@@ -360,7 +379,13 @@
while (iterator.hasNext()) {
MerchantOffer merchantrecipe = (MerchantOffer) iterator.next();
@@ -48,7 +67,7 @@
}
this.resendOffersToTradingPlayer();
@@ -429,7 +443,13 @@
@@ -429,7 +454,13 @@
while (iterator.hasNext()) {
MerchantOffer merchantrecipe = (MerchantOffer) iterator.next();
@@ -63,7 +82,7 @@
}
}
@@ -489,7 +509,7 @@
@@ -489,7 +520,7 @@
@Override
public void addAdditionalSaveData(CompoundTag nbt) {
super.addAdditionalSaveData(nbt);
@@ -72,7 +91,7 @@
Logger logger = Villager.LOGGER;
Objects.requireNonNull(logger);
@@ -512,7 +532,7 @@
@@ -512,7 +543,7 @@
public void readAdditionalSaveData(CompoundTag nbt) {
super.readAdditionalSaveData(nbt);
if (nbt.contains("VillagerData", 10)) {
@@ -81,7 +100,7 @@
Logger logger = Villager.LOGGER;
Objects.requireNonNull(logger);
@@ -808,7 +828,7 @@
@@ -808,7 +839,7 @@
entitywitch1.finalizeSpawn(world, world.getCurrentDifficultyAt(entitywitch1.blockPosition()), EntitySpawnReason.CONVERSION, (SpawnGroupData) null);
entitywitch1.setPersistenceRequired();
this.releaseAllPois();
@@ -90,7 +109,7 @@
if (entitywitch == null) {
super.thunderHit(world, lightning);
@@ -906,7 +926,7 @@
@@ -906,7 +937,7 @@
}).limit(5L).toList();
if (list1.size() >= requiredCount) {
@@ -99,7 +118,7 @@
list.forEach(GolemSensor::golemDetected);
}
}
@@ -963,7 +983,7 @@
@@ -963,7 +994,7 @@
@Override
public void startSleeping(BlockPos pos) {
super.startSleeping(pos);
@@ -108,7 +127,7 @@
this.brain.eraseMemory(MemoryModuleType.WALK_TARGET);
this.brain.eraseMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE);
}
@@ -971,7 +991,7 @@
@@ -971,7 +1002,7 @@
@Override
public void stopSleeping() {
super.stopSleeping();