9
0
mirror of https://github.com/BX-Team/DivineMC.git synced 2025-12-19 14:59:25 +00:00
Files
DivineMC/patches/todo/minecraft-patches/0042-Dynamic-Activation-of-Brain.patch
2025-10-10 01:56:03 +03:00

446 lines
24 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
Date: Sun, 23 Mar 2025 01:16:35 +0300
Subject: [PATCH] Dynamic Activation of Brain
diff --git a/io/papermc/paper/entity/activation/ActivationRange.java b/io/papermc/paper/entity/activation/ActivationRange.java
index ca21597263cb430e2a5ae07e8cecfb0d53a270d2..226088405c019922085285ba5d04d7c131470c69 100644
--- a/io/papermc/paper/entity/activation/ActivationRange.java
+++ b/io/papermc/paper/entity/activation/ActivationRange.java
@@ -167,6 +167,21 @@ public final class ActivationRange {
}
ActivationRange.activateEntity(entity);
+
+ // DivineMC start - Dynamic Activation of Brain
+ if (org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.dabEnabled && entity.getType().dabEnabled && (!org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.dabDontEnableIfInWater || entity.getType().is(net.minecraft.tags.EntityTypeTags.CAN_BREATHE_UNDER_WATER) || !entity.isInWaterOrRain())) {
+ if (!entity.activatedPriorityReset) {
+ entity.activatedPriorityReset = true;
+ entity.activatedPriority = org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.dabMaximumActivationFrequency;
+ }
+ int squaredDistance = (int) player.distanceToSqr(entity);
+ entity.activatedPriority = squaredDistance > org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.dabStartDistanceSquared ?
+ Math.max(1, Math.min(squaredDistance >> org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.dabActivationDistanceMod, entity.activatedPriority)) :
+ 1;
+ } else {
+ entity.activatedPriority = 1;
+ }
+ // DivineMC end - Dynamic Activation of Brain
}
}
}
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
index 421b59b24bda3d03dea8fd0fc6237a71900e1cdc..78bf3365b426e7090182af84630111d410a2460e 100644
--- a/net/minecraft/server/level/ServerLevel.java
+++ b/net/minecraft/server/level/ServerLevel.java
@@ -802,6 +802,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
this.entityTickList
.forEach(
entity -> {
+ entity.activatedPriorityReset = false; // DivineMC - Dynamic Activation of Brain
if (!entity.isRemoved()) {
if (!tickRateManager.isEntityFrozen(entity)) {
entity.checkDespawn();
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index 8808424481bf0c1f89f67d25ba502014d55ebc49..9e53b4297fa786ee863d0cf1855aa0ebd9afc221 100644
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -365,6 +365,8 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
public boolean fixedPose = false; // Paper - Expand Pose API
private final int despawnTime; // Paper - entity despawn time limit
public int totalEntityAge; // Paper - age-like counter for all entities
+ public boolean activatedPriorityReset = false; // DivineMC - Dynamic Activation of Brain
+ public int activatedPriority = org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.dabMaximumActivationFrequency; // DivineMC - Dynamic Activation of Brain
public final io.papermc.paper.entity.activation.ActivationType activationType = io.papermc.paper.entity.activation.ActivationType.activationTypeFor(this); // Paper - EAR 2/tracking ranges
// Paper start - EAR 2
public final boolean defaultActivationState;
diff --git a/net/minecraft/world/entity/EntityType.java b/net/minecraft/world/entity/EntityType.java
index 9950fccc0a708e701b81fcabc9e8f370e6d3a19d..0159627e2c9a540d062073faf9018f5215e10866 100644
--- a/net/minecraft/world/entity/EntityType.java
+++ b/net/minecraft/world/entity/EntityType.java
@@ -1085,6 +1085,7 @@ public class EntityType<T extends Entity> implements FeatureElement, EntityTypeT
private final boolean canSpawnFarFromPlayer;
private final int clientTrackingRange;
private final int updateInterval;
+ public boolean dabEnabled = false; // DivineMC - Dynamic Activation of Brain
private final String descriptionId;
@Nullable
private Component description;
diff --git a/net/minecraft/world/entity/Mob.java b/net/minecraft/world/entity/Mob.java
index 74bd00f5f8ab628d3f35d0f2e39fb1dbf7045c23..faf29073db00f8e10136e03dc877dcfb38f795d0 100644
--- a/net/minecraft/world/entity/Mob.java
+++ b/net/minecraft/world/entity/Mob.java
@@ -210,10 +210,10 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
@Override
public void inactiveTick() {
super.inactiveTick();
- if (this.goalSelector.inactiveTick()) {
+ if (this.goalSelector.inactiveTick(this.activatedPriority, true)) { // DivineMC - Dynamic Activation of Brain
this.goalSelector.tick();
}
- if (this.targetSelector.inactiveTick()) {
+ if (this.targetSelector.inactiveTick(this.activatedPriority, true)) { // DivineMC - Dynamic Activation of Brain
this.targetSelector.tick();
}
}
@@ -773,13 +773,19 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
// Paper end - Allow nerfed mobs to jump and float
this.sensing.tick();
int i = this.tickCount + this.getId();
+ // DivineMC start - Dynamic Activation of Brain
if (i % 2 != 0 && this.tickCount > 1) {
- this.targetSelector.tickRunningGoals(false);
- this.goalSelector.tickRunningGoals(false);
+ if (this.targetSelector.inactiveTick(this.activatedPriority, false))
+ this.targetSelector.tickRunningGoals(false);
+ if (this.goalSelector.inactiveTick(this.activatedPriority, false))
+ this.goalSelector.tickRunningGoals(false);
} else {
- this.targetSelector.tick();
- this.goalSelector.tick();
+ if (this.targetSelector.inactiveTick(this.activatedPriority, false))
+ this.targetSelector.tick();
+ if (this.goalSelector.inactiveTick(this.activatedPriority, false))
+ this.goalSelector.tick();
}
+ // DivineMC end - Dynamic Activation of Brain
this.navigation.tick();
this.customServerAiStep((ServerLevel)this.level());
diff --git a/net/minecraft/world/entity/ai/behavior/VillagerPanicTrigger.java b/net/minecraft/world/entity/ai/behavior/VillagerPanicTrigger.java
index f6c673b1abe53afcb14fd68d590431027ed29f67..1e5312e02298c63c168526a960d688dc03581cee 100644
--- a/net/minecraft/world/entity/ai/behavior/VillagerPanicTrigger.java
+++ b/net/minecraft/world/entity/ai/behavior/VillagerPanicTrigger.java
@@ -36,7 +36,11 @@ public class VillagerPanicTrigger extends Behavior<Villager> {
@Override
protected void tick(ServerLevel level, Villager owner, long gameTime) {
- if (gameTime % 100L == 0L) {
+ // DivineMC start - Dynamic Activation of Brain
+ if (owner.nextGolemPanic < 0) owner.nextGolemPanic = gameTime + 100;
+ if (--owner.nextGolemPanic < gameTime) {
+ owner.nextGolemPanic = -1;
+ // DivineMC end - Dynamic Activation of Brain
owner.spawnGolemIfNeeded(level, gameTime, 3);
}
}
diff --git a/net/minecraft/world/entity/ai/goal/GoalSelector.java b/net/minecraft/world/entity/ai/goal/GoalSelector.java
index 653c58c7637c46c8b46a5082f671324a2221d431..a4328a427636aa845d6627ecb75a9efe7320bb15 100644
--- a/net/minecraft/world/entity/ai/goal/GoalSelector.java
+++ b/net/minecraft/world/entity/ai/goal/GoalSelector.java
@@ -34,10 +34,14 @@ public class GoalSelector {
}
// Paper start - EAR 2
- public boolean inactiveTick() {
+ // DivineMC start - Dynamic Activation of Brain
+ public boolean inactiveTick(int tickRate, boolean inactive) {
+ if (inactive && !org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.dabEnabled) tickRate = 4;
+ tickRate = Math.min(tickRate, 3);
this.curRate++;
- return this.curRate % 3 == 0; // TODO newGoalRate was already unused in 1.20.4, check if this is correct
+ return this.curRate % tickRate == 0;
}
+ // DivineMC end - Dynamic Activation of Brain
public boolean hasTasks() {
for (WrappedGoal task : this.availableGoals) {
diff --git a/net/minecraft/world/entity/animal/allay/Allay.java b/net/minecraft/world/entity/animal/allay/Allay.java
index dd10b0535baf48aea47020d890f102800b0af11a..e0c4dc78c669fd53e0c03c3013eb439e4a07c690 100644
--- a/net/minecraft/world/entity/animal/allay/Allay.java
+++ b/net/minecraft/world/entity/animal/allay/Allay.java
@@ -113,6 +113,7 @@ public class Allay extends PathfinderMob implements InventoryCarrier, VibrationS
private float spinningAnimationTicks0;
public boolean forceDancing = false; // CraftBukkit
private org.purpurmc.purpur.controller.FlyingMoveControllerWASD purpurController; // Purpur - Ridables
+ private int behaviorTick = 0; // DivineMC - Dynamic Activation of Brain
public Allay(EntityType<? extends Allay> entityType, Level level) {
super(entityType, level);
@@ -267,10 +268,13 @@ public class Allay extends PathfinderMob implements InventoryCarrier, VibrationS
@Override
protected void customServerAiStep(ServerLevel level) {
- if ((getRider() == null || !this.isControllable())) // Purpur - only use brain if no rider
- this.getBrain().tick(level, this);
- AllayAi.updateActivity(this);
- super.customServerAiStep(level);
+ // DivineMC start - Dynamic Activation of Brain
+ if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) { // Purpur - only use brain if no rider
+ this.getBrain().tick(level, this);
+ AllayAi.updateActivity(this);
+ super.customServerAiStep(level);
+ }
+ // DivineMC end - Dynamic Activation of Brain
}
@Override
diff --git a/net/minecraft/world/entity/animal/axolotl/Axolotl.java b/net/minecraft/world/entity/animal/axolotl/Axolotl.java
index deb2fdea7be9dda1c4b267ac25326bb9b05ae739..ab13d9c2aedda17c8cbc911e678aac8b6b28801d 100644
--- a/net/minecraft/world/entity/animal/axolotl/Axolotl.java
+++ b/net/minecraft/world/entity/animal/axolotl/Axolotl.java
@@ -112,6 +112,7 @@ public class Axolotl extends Animal implements Bucketable {
public final BinaryAnimator onGroundAnimator = new BinaryAnimator(10, Mth::easeInOutSine);
public final BinaryAnimator movingAnimator = new BinaryAnimator(10, Mth::easeInOutSine);
private static final int REGEN_BUFF_BASE_DURATION = 100;
+ private int behaviorTick = 0; // DivineMC - Dynamic Activation of Brain
public Axolotl(EntityType<? extends Axolotl> entityType, Level level) {
super(entityType, level);
@@ -373,13 +374,16 @@ public class Axolotl extends Animal implements Bucketable {
@Override
protected void customServerAiStep(ServerLevel level) {
- if ((getRider() == null || !this.isControllable())) // Purpur - only use brain if no rider
- this.getBrain().tick(level, this);
- AxolotlAi.updateActivity(this);
- if (!this.isNoAi()) {
- Optional<Integer> memory = this.getBrain().getMemory(MemoryModuleType.PLAY_DEAD_TICKS);
- this.setPlayingDead(memory.isPresent() && memory.get() > 0);
+ // DivineMC start - Dynamic Activation of Brain
+ if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) { // Purpur - only use brain if no rider
+ this.getBrain().tick(level, this);
+ AxolotlAi.updateActivity(this);
+ if (!this.isNoAi()) {
+ Optional<Integer> memory = this.getBrain().getMemory(MemoryModuleType.PLAY_DEAD_TICKS);
+ this.setPlayingDead(memory.isPresent() && memory.get() > 0);
+ }
}
+ // DivineMC end - Dynamic Activation of Brain
}
public static AttributeSupplier.Builder createAttributes() {
diff --git a/net/minecraft/world/entity/animal/frog/Frog.java b/net/minecraft/world/entity/animal/frog/Frog.java
index f67d18f32f73e0e6be35939781bd0bd0188cdfbd..f526a426d02f8fb1ce6c1b16e0ed3edae8ab5271 100644
--- a/net/minecraft/world/entity/animal/frog/Frog.java
+++ b/net/minecraft/world/entity/animal/frog/Frog.java
@@ -106,6 +106,7 @@ public class Frog extends Animal {
public final AnimationState swimIdleAnimationState = new AnimationState();
private org.purpurmc.purpur.controller.MoveControllerWASD purpurLandController; // Purpur - Ridables
private org.purpurmc.purpur.controller.WaterMoveControllerWASD purpurWaterController; // Purpur - Ridables
+ private int behaviorTick = 0; // DivineMC - Dynamic Activation of Brain
public Frog(EntityType<? extends Animal> entityType, Level level) {
super(entityType, level);
@@ -259,10 +260,13 @@ public class Frog extends Animal {
@Override
protected void customServerAiStep(ServerLevel level) {
- if ((getRider() == null || !this.isControllable())) // Purpur - only use brain if no rider
- this.getBrain().tick(level, this);
- FrogAi.updateActivity(this);
- super.customServerAiStep(level);
+ // DivineMC start - Dynamic Activation of Brain
+ if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) { // Purpur - only use brain if no rider
+ this.getBrain().tick(level, this);
+ FrogAi.updateActivity(this);
+ super.customServerAiStep(level);
+ }
+ // DivineMC end - Dynamic Activation of Brain
}
@Override
diff --git a/net/minecraft/world/entity/animal/frog/Tadpole.java b/net/minecraft/world/entity/animal/frog/Tadpole.java
index c25cfd8f176819efd64e5ce45632b0cc1b69d420..f654228b59950e1f866d8decf208eb4f1a5ff603 100644
--- a/net/minecraft/world/entity/animal/frog/Tadpole.java
+++ b/net/minecraft/world/entity/animal/frog/Tadpole.java
@@ -65,6 +65,7 @@ public class Tadpole extends AbstractFish {
);
public boolean ageLocked; // Paper
private org.purpurmc.purpur.controller.WaterMoveControllerWASD purpurController; // Purpur - Ridables
+ private int behaviorTick = 0; // DivineMC - Dynamic Activation of Brain
public Tadpole(EntityType<? extends AbstractFish> entityType, Level level) {
super(entityType, level);
@@ -135,10 +136,13 @@ public class Tadpole extends AbstractFish {
@Override
protected void customServerAiStep(ServerLevel level) {
- if ((getRider() == null || !this.isControllable())) // Purpur - only use brain if no rider
- this.getBrain().tick(level, this);
- TadpoleAi.updateActivity(this);
- super.customServerAiStep(level);
+ // DivineMC start - Dynamic Activation of Brain
+ if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) { // Purpur - only use brain if no rider
+ this.getBrain().tick(level, this);
+ TadpoleAi.updateActivity(this);
+ super.customServerAiStep(level);
+ }
+ // DivineMC end - Dynamic Activation of Brain
}
public static AttributeSupplier.Builder createAttributes() {
diff --git a/net/minecraft/world/entity/animal/goat/Goat.java b/net/minecraft/world/entity/animal/goat/Goat.java
index 934853721c000186e4a97b05ad26c59d7e84dd55..4913e44112da5c43b36e4e4e456ccebecc8e7cc3 100644
--- a/net/minecraft/world/entity/animal/goat/Goat.java
+++ b/net/minecraft/world/entity/animal/goat/Goat.java
@@ -94,6 +94,7 @@ public class Goat extends Animal {
private static final boolean DEFAULT_HAS_RIGHT_HORN = true;
private boolean isLoweringHead;
private int lowerHeadTick;
+ private int behaviorTick = 0; // DivineMC - Dynamic Activation of Brain
public Goat(EntityType<? extends Goat> entityType, Level level) {
super(entityType, level);
@@ -233,10 +234,13 @@ public class Goat extends Animal {
@Override
protected void customServerAiStep(ServerLevel level) {
- if ((getRider() == null || !this.isControllable())) // Purpur - only use brain if no rider
- this.getBrain().tick(level, this);
- GoatAi.updateActivity(this);
- super.customServerAiStep(level);
+ // DivineMC start - Dynamic Activation of Brain
+ if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) { // Purpur - only use brain if no rider
+ this.getBrain().tick(level, this);
+ GoatAi.updateActivity(this);
+ super.customServerAiStep(level);
+ }
+ // DivineMC end - Dynamic Activation of Brain
}
@Override
diff --git a/net/minecraft/world/entity/monster/hoglin/Hoglin.java b/net/minecraft/world/entity/monster/hoglin/Hoglin.java
index 952fba6d141576089e563e829cae4a177f19d639..ba0ec0eb69742df84435102f6871cf1ab94b3aca 100644
--- a/net/minecraft/world/entity/monster/hoglin/Hoglin.java
+++ b/net/minecraft/world/entity/monster/hoglin/Hoglin.java
@@ -88,6 +88,7 @@ public class Hoglin extends Animal implements Enemy, HoglinBase {
MemoryModuleType.PACIFIED,
MemoryModuleType.IS_PANICKING
);
+ private int behaviorTick; // DivineMC - Dynamic Activation of Brain
public Hoglin(EntityType<? extends Hoglin> entityType, Level level) {
super(entityType, level);
@@ -206,18 +207,21 @@ public class Hoglin extends Animal implements Enemy, HoglinBase {
@Override
protected void customServerAiStep(ServerLevel level) {
- if ((getRider() == null || !this.isControllable())) // Purpur - only use brain if no rider
- this.getBrain().tick(level, this);
- HoglinAi.updateActivity(this);
- if (this.isConverting()) {
- this.timeInOverworld++;
- if (this.timeInOverworld > 300) {
- this.makeSound(SoundEvents.HOGLIN_CONVERTED_TO_ZOMBIFIED);
- this.finishConversion();
+ // DivineMC start - Dynamic Activation of Brain
+ if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) { // Purpur - only use brain if no rider
+ this.getBrain().tick(level, this);
+ HoglinAi.updateActivity(this);
+ if (this.isConverting()) {
+ this.timeInOverworld++;
+ if (this.timeInOverworld > 300) {
+ this.makeSound(SoundEvents.HOGLIN_CONVERTED_TO_ZOMBIFIED);
+ this.finishConversion();
+ }
+ } else {
+ this.timeInOverworld = 0;
}
- } else {
- this.timeInOverworld = 0;
}
+ // DivineMC end - Dynamic Activation of Brain
}
@Override
diff --git a/net/minecraft/world/entity/monster/piglin/Piglin.java b/net/minecraft/world/entity/monster/piglin/Piglin.java
index 03b6640c95c86ea9f6219d6e39feffa4643dd648..74e753a9a2b4e4132558c39d3d8a5424d819e78b 100644
--- a/net/minecraft/world/entity/monster/piglin/Piglin.java
+++ b/net/minecraft/world/entity/monster/piglin/Piglin.java
@@ -129,6 +129,7 @@ public class Piglin extends AbstractPiglin implements CrossbowAttackMob, Invento
private static final com.mojang.serialization.Codec<java.util.Set<net.minecraft.world.item.Item>> ITEM_SET_CODEC = net.minecraft.core.registries.BuiltInRegistries.ITEM
.byNameCodec().listOf().xmap(java.util.HashSet::new, List::copyOf);
// CraftBukkit end
+ private int behaviorTick; // DivineMC - Dynamic Activation of Brain
public Piglin(EntityType<? extends AbstractPiglin> entityType, Level level) {
super(entityType, level);
@@ -357,10 +358,13 @@ public class Piglin extends AbstractPiglin implements CrossbowAttackMob, Invento
@Override
protected void customServerAiStep(ServerLevel level) {
- if ((getRider() == null || !this.isControllable())) // Purpur - only use brain if no rider
- this.getBrain().tick(level, this);
- PiglinAi.updateActivity(this);
- super.customServerAiStep(level);
+ // DivineMC start - Dynamic Activation of Brain
+ if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) { // Purpur - only use brain if no rider
+ this.getBrain().tick(level, this);
+ PiglinAi.updateActivity(this);
+ super.customServerAiStep(level);
+ }
+ // DivineMC end - Dynamic Activation of Brain
}
@Override
diff --git a/net/minecraft/world/entity/monster/warden/Warden.java b/net/minecraft/world/entity/monster/warden/Warden.java
index 091b9cc338e37efbecdd4187a9824dae7bff2af9..808661fdefacfffa65ebde1aa3193a82497706b7 100644
--- a/net/minecraft/world/entity/monster/warden/Warden.java
+++ b/net/minecraft/world/entity/monster/warden/Warden.java
@@ -108,6 +108,7 @@ public class Warden extends Monster implements VibrationSystem {
private final VibrationSystem.User vibrationUser;
private VibrationSystem.Data vibrationData;
AngerManagement angerManagement = new AngerManagement(this::canTargetEntity, Collections.emptyList());
+ private int behaviorTick = 0; // DivineMC - Dynamic Activation of Brain
public Warden(EntityType<? extends Monster> entityType, Level level) {
super(entityType, level);
@@ -301,19 +302,22 @@ public class Warden extends Monster implements VibrationSystem {
@Override
protected void customServerAiStep(ServerLevel level) {
- if ((getRider() == null || !this.isControllable())) // Purpur - only use brain if no rider
- this.getBrain().tick(level, this);
- super.customServerAiStep(level);
- if ((this.tickCount + this.getId()) % 120 == 0) {
- applyDarknessAround(level, this.position(), this, 20);
- }
+ // DivineMC start - Dynamic Activation of Brain
+ if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) { // Purpur - only use brain if no rider
+ this.getBrain().tick(level, this);
+ super.customServerAiStep(level);
+ if ((this.tickCount + this.getId()) % 120 == 0) {
+ applyDarknessAround(level, this.position(), this, 20);
+ }
- if (this.tickCount % 20 == 0) {
- this.angerManagement.tick(level, this::canTargetEntity);
- this.syncClientAngerLevel();
- }
+ if (this.tickCount % 20 == 0) {
+ this.angerManagement.tick(level, this::canTargetEntity);
+ this.syncClientAngerLevel();
+ }
- WardenAi.updateActivity(this);
+ WardenAi.updateActivity(this);
+ }
+ // DivineMC end - Dynamic Activation of Brain
}
@Override
diff --git a/net/minecraft/world/entity/npc/Villager.java b/net/minecraft/world/entity/npc/Villager.java
index db5c287161c50bafd672b9cb439b3a06b1ff16d7..c2c6f5e8837ae2ac685b56562686b552b3e1bd8f 100644
--- a/net/minecraft/world/entity/npc/Villager.java
+++ b/net/minecraft/world/entity/npc/Villager.java
@@ -178,6 +178,8 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
);
private boolean isLobotomized = false; public boolean isLobotomized() { return this.isLobotomized; } // Purpur - Lobotomize stuck villagers
private int notLobotomizedCount = 0; // Purpur - Lobotomize stuck villagers
+ public long nextGolemPanic = -1; // DivineMC - Dynamic Activation of Brain
+ private int behaviorTick = 0; // DivineMC - Dynamic Activation of Brain
public Villager(EntityType<? extends Villager> entityType, Level level) {
this(entityType, level, VillagerType.PLAINS);
@@ -399,7 +401,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
this.isLobotomized = false;
}
// Purpur end - Lobotomize stuck villagers
- if (!inactive && (getRider() == null || !this.isControllable())) { // Purpur - Ridables
+ if (!inactive && this.behaviorTick++ % this.activatedPriority == 0 && (getRider() == null || !this.isControllable())) { // Purpur - Ridables // DivineMC - Dynamic Activation of Brain
this.getBrain().tick(level, this); // Paper - EAR 2
}
else if (this.isLobotomized && shouldRestock()) restock(); // Purpur - Lobotomize stuck villagers