mirror of
https://github.com/BX-Team/DivineMC.git
synced 2025-12-22 16:29:23 +00:00
add DAB
This commit is contained in:
@@ -0,0 +1,437 @@
|
|||||||
|
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 ae0a3c3d9d6300293a6d0dff5cae49ebe7c11dab..3b08dad7a9fac7ac9acec0bfb85d4826452bdc99 100644
|
||||||
|
--- a/io/papermc/paper/entity/activation/ActivationRange.java
|
||||||
|
+++ b/io/papermc/paper/entity/activation/ActivationRange.java
|
||||||
|
@@ -161,6 +161,21 @@ public final class ActivationRange {
|
||||||
|
}
|
||||||
|
|
||||||
|
ActivationRange.activateEntity(entity);
|
||||||
|
+
|
||||||
|
+ // DivineMC start - Dynamic Activation of Brain
|
||||||
|
+ if (org.bxteam.divinemc.DivineConfig.dabEnabled && entity.getType().dabEnabled && (!org.bxteam.divinemc.DivineConfig.dabDontEnableIfInWater || entity.getType().is(net.minecraft.tags.EntityTypeTags.CAN_BREATHE_UNDER_WATER) || !entity.isInWaterOrBubble())) {
|
||||||
|
+ if (!entity.activatedPriorityReset) {
|
||||||
|
+ entity.activatedPriorityReset = true;
|
||||||
|
+ entity.activatedPriority = org.bxteam.divinemc.DivineConfig.dabMaximumActivationFrequency;
|
||||||
|
+ }
|
||||||
|
+ int squaredDistance = (int) player.distanceToSqr(entity);
|
||||||
|
+ entity.activatedPriority = squaredDistance > org.bxteam.divinemc.DivineConfig.dabStartDistanceSquared ?
|
||||||
|
+ Math.max(1, Math.min(squaredDistance >> org.bxteam.divinemc.DivineConfig.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 da395fcf672e2c055ea0687d26fa5d31b8fc4640..6c919ebe8b477080727744ff1af6307e025f213a 100644
|
||||||
|
--- a/net/minecraft/server/level/ServerLevel.java
|
||||||
|
+++ b/net/minecraft/server/level/ServerLevel.java
|
||||||
|
@@ -816,6 +816,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 96775eadaac9afb600b5c1b553db40970d9d7a3d..b6becf5e14abddcb60b1f4c4babecfe81cf5c09c 100644
|
||||||
|
--- a/net/minecraft/world/entity/Entity.java
|
||||||
|
+++ b/net/minecraft/world/entity/Entity.java
|
||||||
|
@@ -336,6 +336,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.DivineConfig.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 4186db5cb8d2cd29ebc230d704dd125ae0dfa358..79593dc0e42e4cf0aee5e7b8cac4aca186887d6f 100644
|
||||||
|
--- a/net/minecraft/world/entity/EntityType.java
|
||||||
|
+++ b/net/minecraft/world/entity/EntityType.java
|
||||||
|
@@ -1063,6 +1063,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 b4e19cc65701d5ef94e1cc0a7473225c222725c3..00daf8de01bf23f55ba8af12d3e3e551d981c61c 100644
|
||||||
|
--- a/net/minecraft/world/entity/Mob.java
|
||||||
|
+++ b/net/minecraft/world/entity/Mob.java
|
||||||
|
@@ -218,10 +218,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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -888,13 +888,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 b816b2de8eb327060ca6ea7c4afc17373fa77ff6..4eed0bd3670fdcb0a156c29e7db63233a47f539b 100644
|
||||||
|
--- a/net/minecraft/world/entity/ai/goal/GoalSelector.java
|
||||||
|
+++ b/net/minecraft/world/entity/ai/goal/GoalSelector.java
|
||||||
|
@@ -36,10 +36,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.DivineConfig.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 b2c9da89ae6044536f4996fdbd37e2cabf22ca12..fa9672e890f327dbdec57eadc258bbae8e98e91e 100644
|
||||||
|
--- a/net/minecraft/world/entity/animal/allay/Allay.java
|
||||||
|
+++ b/net/minecraft/world/entity/animal/allay/Allay.java
|
||||||
|
@@ -118,6 +118,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);
|
||||||
|
@@ -287,9 +288,13 @@ public class Allay extends PathfinderMob implements InventoryCarrier, VibrationS
|
||||||
|
@Override
|
||||||
|
protected void customServerAiStep(ServerLevel level) {
|
||||||
|
//if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish // 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 (this.behaviorTick++ % this.activatedPriority == 0) {
|
||||||
|
+ 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 bbfe48fd278cda9926793d0d2de743558fefd622..3f7c48282577a2de20e78b69ddcbc08347318fd3 100644
|
||||||
|
--- a/net/minecraft/world/entity/animal/axolotl/Axolotl.java
|
||||||
|
+++ b/net/minecraft/world/entity/animal/axolotl/Axolotl.java
|
||||||
|
@@ -105,6 +105,7 @@ public class Axolotl extends Animal implements VariantHolder<Axolotl.Variant>, B
|
||||||
|
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);
|
||||||
|
@@ -347,12 +348,16 @@ public class Axolotl extends Animal implements VariantHolder<Axolotl.Variant>, B
|
||||||
|
@Override
|
||||||
|
protected void customServerAiStep(ServerLevel level) {
|
||||||
|
//if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish // 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 (this.behaviorTick++ % this.activatedPriority == 0) {
|
||||||
|
+ 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 dfcba5c2c8a489ebe74c2d5c1fa980c401806757..1827dead0a0a1d8e9dfbcc44038c9dbfbefddd48 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 implements VariantHolder<Holder<FrogVariant>> {
|
||||||
|
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);
|
||||||
|
@@ -242,9 +243,13 @@ public class Frog extends Animal implements VariantHolder<Holder<FrogVariant>> {
|
||||||
|
@Override
|
||||||
|
protected void customServerAiStep(ServerLevel level) {
|
||||||
|
//if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish // 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 (this.behaviorTick++ % this.activatedPriority == 0) {
|
||||||
|
+ 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 78d256f6a95acb367efd690bc368d2106a928b8f..b32fabed65f929cb8d2c8c93667f2e45b9bef0b8 100644
|
||||||
|
--- a/net/minecraft/world/entity/animal/frog/Tadpole.java
|
||||||
|
+++ b/net/minecraft/world/entity/animal/frog/Tadpole.java
|
||||||
|
@@ -62,6 +62,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);
|
||||||
|
@@ -133,9 +134,13 @@ public class Tadpole extends AbstractFish {
|
||||||
|
@Override
|
||||||
|
protected void customServerAiStep(ServerLevel level) {
|
||||||
|
//if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish // 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 (this.behaviorTick++ % this.activatedPriority == 0) {
|
||||||
|
+ 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 e21f024d0ed7f936ff17df16bd9666fffbf44a75..1f46d9e9def33458001c4c30bf2e37486646d23f 100644
|
||||||
|
--- a/net/minecraft/world/entity/animal/goat/Goat.java
|
||||||
|
+++ b/net/minecraft/world/entity/animal/goat/Goat.java
|
||||||
|
@@ -90,6 +90,7 @@ public class Goat extends Animal {
|
||||||
|
public static final EntityDataAccessor<Boolean> DATA_HAS_RIGHT_HORN = SynchedEntityData.defineId(Goat.class, EntityDataSerializers.BOOLEAN);
|
||||||
|
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);
|
||||||
|
@@ -230,9 +231,13 @@ public class Goat extends Animal {
|
||||||
|
@Override
|
||||||
|
protected void customServerAiStep(ServerLevel level) {
|
||||||
|
//if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish // 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 (this.behaviorTick++ % this.activatedPriority == 0) {
|
||||||
|
+ 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 a5ee49e35b0825c03af058347ee189a7962e8027..4a02ff2dbea64cf6fb867872c08ad1b80fc5145b 100644
|
||||||
|
--- a/net/minecraft/world/entity/monster/hoglin/Hoglin.java
|
||||||
|
+++ b/net/minecraft/world/entity/monster/hoglin/Hoglin.java
|
||||||
|
@@ -84,6 +84,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);
|
||||||
|
@@ -203,17 +204,21 @@ public class Hoglin extends Animal implements Enemy, HoglinBase {
|
||||||
|
@Override
|
||||||
|
protected void customServerAiStep(ServerLevel level) {
|
||||||
|
//if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish // 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 (this.behaviorTick++ % this.activatedPriority == 0) {
|
||||||
|
+ 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 b2e64c0d4c1943f8a50a03ba59318fc2e6b9e26a..a7f2c0aec77a8b196c9207b071ac904c30f34ee6 100644
|
||||||
|
--- a/net/minecraft/world/entity/monster/piglin/Piglin.java
|
||||||
|
+++ b/net/minecraft/world/entity/monster/piglin/Piglin.java
|
||||||
|
@@ -143,6 +143,7 @@ public class Piglin extends AbstractPiglin implements CrossbowAttackMob, Invento
|
||||||
|
public Set<Item> allowedBarterItems = new HashSet<>();
|
||||||
|
public Set<Item> interestItems = new HashSet<>();
|
||||||
|
// CraftBukkit end
|
||||||
|
+ private int behaviorTick; // DivineMC - Dynamic Activation of Brain
|
||||||
|
|
||||||
|
public Piglin(EntityType<? extends AbstractPiglin> entityType, Level level) {
|
||||||
|
super(entityType, level);
|
||||||
|
@@ -382,9 +383,13 @@ public class Piglin extends AbstractPiglin implements CrossbowAttackMob, Invento
|
||||||
|
@Override
|
||||||
|
protected void customServerAiStep(ServerLevel level) {
|
||||||
|
//if ((getRider() == null || !this.isControllable()) && this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish // 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 (this.behaviorTick++ % this.activatedPriority == 0) {
|
||||||
|
+ 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 59a12809e5c7f5ee85ca1f587f6b77383a1ff062..9777f5e99909790b49b05ea64fe12dedaaba6a0a 100644
|
||||||
|
--- a/net/minecraft/world/entity/monster/warden/Warden.java
|
||||||
|
+++ b/net/minecraft/world/entity/monster/warden/Warden.java
|
||||||
|
@@ -113,6 +113,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);
|
||||||
|
@@ -306,18 +307,22 @@ public class Warden extends Monster implements VibrationSystem {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void customServerAiStep(ServerLevel level) {
|
||||||
|
- 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 (this.behaviorTick++ % this.activatedPriority == 0) {
|
||||||
|
+ 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 fec90e482c8935dfca609bbf90e67f86a1586221..2ac8a11e9afc6f776eba3dbe852d7b680ed21705 100644
|
||||||
|
--- a/net/minecraft/world/entity/npc/Villager.java
|
||||||
|
+++ b/net/minecraft/world/entity/npc/Villager.java
|
||||||
|
@@ -179,6 +179,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);
|
||||||
|
@@ -397,7 +399,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||||
|
}
|
||||||
|
// Purpur end - Lobotomize stuck villagers
|
||||||
|
// Pufferfish start
|
||||||
|
- if (!inactive && (getRider() == null || !this.isControllable()) /*&& this.behaviorTick++ % this.activatedPriority == 0*/) { // Purpur - Ridables
|
||||||
|
+ if (!inactive && this.behaviorTick++ % this.activatedPriority == 0 && (getRider() == null || !this.isControllable()) /*&& this.behaviorTick++ % this.activatedPriority == 0*/) { // 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
|
||||||
@@ -1,6 +1,9 @@
|
|||||||
package org.bxteam.divinemc;
|
package org.bxteam.divinemc;
|
||||||
|
|
||||||
import com.google.common.base.Throwables;
|
import com.google.common.base.Throwables;
|
||||||
|
import net.minecraft.core.registries.BuiltInRegistries;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.world.entity.EntityType;
|
||||||
import org.apache.logging.log4j.Level;
|
import org.apache.logging.log4j.Level;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
@@ -20,7 +23,9 @@ import java.io.IOException;
|
|||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
@SuppressWarnings({"unused", "SameParameterValue"})
|
@SuppressWarnings({"unused", "SameParameterValue"})
|
||||||
public class DivineConfig {
|
public class DivineConfig {
|
||||||
@@ -431,6 +436,49 @@ public class DivineConfig {
|
|||||||
"Uses virtual threads for the server text filter pool.");
|
"Uses virtual threads for the server text filter pool.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean dabEnabled = true;
|
||||||
|
public static int dabStartDistance = 12;
|
||||||
|
public static int dabStartDistanceSquared;
|
||||||
|
public static int dabMaximumActivationFrequency = 20;
|
||||||
|
public static int dabActivationDistanceMod = 8;
|
||||||
|
public static boolean dabDontEnableIfInWater = false;
|
||||||
|
public static List<String> dabBlackedEntities = new ArrayList<>();
|
||||||
|
private static void dab() {
|
||||||
|
dabEnabled = getBoolean("settings.dab.enabled", dabEnabled,
|
||||||
|
"Enables DAB feature");
|
||||||
|
dabStartDistance = getInt("settings.dab.start-distance", dabStartDistance,
|
||||||
|
"This value determines how far away an entity has to be");
|
||||||
|
dabStartDistanceSquared = dabStartDistance * dabStartDistance;
|
||||||
|
dabMaximumActivationFrequency = getInt("settings.dab.maximum-activation-frequency", dabMaximumActivationFrequency,
|
||||||
|
"How often in ticks, the furthest entity will get their pathfinders and behaviors ticked.");
|
||||||
|
dabActivationDistanceMod = getInt("settings.dab.activation-distance-mod", dabActivationDistanceMod,
|
||||||
|
"Modifies an entity's tick frequency.",
|
||||||
|
"The exact calculation to obtain the tick frequency for an entity is: freq = (distanceToPlayer^2) / (2^value), where value is this configuration setting.",
|
||||||
|
"Large servers may want to reduce the value to 7, but this value should never be reduced below 6. If you want further away entities to tick more often, set the value to 9");
|
||||||
|
dabDontEnableIfInWater = getBoolean("settings.dab.dont-enable-if-in-water", dabDontEnableIfInWater,
|
||||||
|
"When this is enabled, non-aquatic entities in the water will not be affected by DAB.");
|
||||||
|
dabBlackedEntities = getStringList("settings.dab.blacked-entities", dabBlackedEntities,
|
||||||
|
"Use this configuration option to specify that certain entities should not be impacted by DAB.");
|
||||||
|
|
||||||
|
setComment("settings.dab",
|
||||||
|
"DAB is an optimization that reduces the frequency of brain ticks. Brain ticks are very intensive, which is why they",
|
||||||
|
"are limited. DAB can be tuned to meet your preferred performance-experience tradeoff. The farther away entities",
|
||||||
|
"are from players, the less frequently their brains will be ticked. While DAB does impact the AI goal selector",
|
||||||
|
"behavior of all entities, the only entities who's brain ticks are limited are: Villager, Axolotl, Hoglin, Zombified Piglin and Goat");
|
||||||
|
|
||||||
|
for (EntityType<?> entityType : BuiltInRegistries.ENTITY_TYPE) {
|
||||||
|
entityType.dabEnabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String DEFAULT_PREFIX = ResourceLocation.DEFAULT_NAMESPACE + ResourceLocation.NAMESPACE_SEPARATOR;
|
||||||
|
for (String name : dabBlackedEntities) {
|
||||||
|
String lowerName = name.toLowerCase(Locale.ROOT);
|
||||||
|
String typeId = lowerName.startsWith(DEFAULT_PREFIX) ? lowerName : DEFAULT_PREFIX + lowerName;
|
||||||
|
|
||||||
|
EntityType.byString(typeId).ifPresentOrElse(entityType -> entityType.dabEnabled = false, () -> LOGGER.warn("Unknown entity {}, in {}", name, "settings.dab.blacked-entities"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean asyncPathfinding = true;
|
public static boolean asyncPathfinding = true;
|
||||||
public static int asyncPathfindingMaxThreads = 2;
|
public static int asyncPathfindingMaxThreads = 2;
|
||||||
public static int asyncPathfindingKeepalive = 60;
|
public static int asyncPathfindingKeepalive = 60;
|
||||||
|
|||||||
Reference in New Issue
Block a user