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

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/AgeableMob.java
+++ b/net/minecraft/world/entity/AgeableMob.java
@@ -21,6 +21,7 @@
@@ -21,12 +21,38 @@
protected int age;
protected int forcedAge;
protected int forcedAgeTimer;
@@ -8,7 +8,38 @@
protected AgeableMob(EntityType<? extends AgeableMob> type, Level world) {
super(type, world);
@@ -104,6 +105,7 @@
}
+ // Spigot start
@Override
+ public void inactiveTick()
+ {
+ super.inactiveTick();
+ if ( this.level().isClientSide || this.ageLocked )
+ { // CraftBukkit
+ this.refreshDimensions();
+ } else
+ {
+ int i = this.getAge();
+
+ if ( i < 0 )
+ {
+ ++i;
+ this.setAge( i );
+ } else if ( i > 0 )
+ {
+ --i;
+ this.setAge( i );
+ }
+ }
+ }
+ // Spigot end
+
+ @Override
public SpawnGroupData finalizeSpawn(ServerLevelAccessor world, DifficultyInstance difficulty, EntitySpawnReason spawnReason, @Nullable SpawnGroupData entityData) {
if (entityData == null) {
entityData = new AgeableMob.AgeableMobGroupData(true);
@@ -104,6 +130,7 @@
super.addAdditionalSaveData(nbt);
nbt.putInt("Age", this.getAge());
nbt.putInt("ForcedAge", this.forcedAge);
@@ -16,7 +47,7 @@
}
@Override
@@ -111,6 +113,7 @@
@@ -111,6 +138,7 @@
super.readAdditionalSaveData(nbt);
this.setAge(nbt.getInt("Age"));
this.forcedAge = nbt.getInt("ForcedAge");
@@ -24,7 +55,7 @@
}
@Override
@@ -125,7 +128,7 @@
@@ -125,7 +153,7 @@
@Override
public void aiStep() {
super.aiStep();