419 lines
22 KiB
Diff
419 lines
22 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: MrHua269 <novau233@163.com>
|
|
Date: Sat, 27 Jan 2024 12:23:09 +0000
|
|
Subject: [PATCH] Pufferfish Dynamic Activation of Brain
|
|
|
|
|
|
diff --git a/src/main/java/me/earthme/luminol/LuminolConfig.java b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
|
index 11c1a367fbc25cb63738a00ad93fb0b0b3500e7d..fead5b1be39083f3fe28be8c41dc78dcac4b59da 100644
|
|
--- a/src/main/java/me/earthme/luminol/LuminolConfig.java
|
|
+++ b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
|
@@ -11,13 +11,16 @@ import org.apache.logging.log4j.LogManager;
|
|
import org.apache.logging.log4j.Logger;
|
|
import org.bukkit.Bukkit;
|
|
|
|
-import java.util.Arrays;
|
|
-import java.util.List;
|
|
-import java.util.Locale;
|
|
+import java.util.*;
|
|
import java.util.logging.Level;
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
|
|
+import net.minecraft.core.registries.BuiltInRegistries;
|
|
+import net.minecraft.server.MinecraftServer;
|
|
+import org.bukkit.configuration.ConfigurationSection;
|
|
+import net.minecraft.world.entity.EntityType;
|
|
+
|
|
public class LuminolConfig {
|
|
private static final Logger logger = LogManager.getLogger();
|
|
private static final File PARENT_FOLDER = new File("luminol_config");
|
|
@@ -48,6 +51,12 @@ public class LuminolConfig {
|
|
public static boolean enableSuffocationOptimization = true;
|
|
public static int maxProjectileLoadsPerTick;
|
|
public static int maxProjectileLoadsPerProjectile;
|
|
+ public static boolean dearEnabled;
|
|
+ public static int startDistance;
|
|
+ public static int startDistanceSquared;
|
|
+ public static int maximumActivationPrio;
|
|
+ public static int activationDistanceMod;
|
|
+
|
|
|
|
public static void init() throws IOException {
|
|
PARENT_FOLDER.mkdir();
|
|
@@ -86,6 +95,33 @@ public class LuminolConfig {
|
|
}
|
|
}
|
|
|
|
+ private static void initDAB(){
|
|
+ dearEnabled = get("optimizations.dab.enabled", false);
|
|
+ startDistance = get("optimizations.dab.start-distance", 12,
|
|
+ "This value determines how far away an entity has to be\n"+
|
|
+ "from the player to start being effected by DEAR.");
|
|
+ startDistanceSquared = startDistance * startDistance;
|
|
+ maximumActivationPrio = get("optimizations.dab.max-tick-freq",20,
|
|
+ "This value defines how often in ticks, the furthest entity\n"+
|
|
+ "will get their pathfinders and behaviors ticked. 20 = 1s");
|
|
+ activationDistanceMod = get("optimizations.dab.activation-dist-mod",8,
|
|
+ """
|
|
+ This value defines how much distance modifies an entity's
|
|
+ tick frequency. freq = (distanceToPlayer^2) / (2^value)
|
|
+ If you want further away entities to tick less often, use 7.
|
|
+ If you want further away entities to tick more often, try 9.""");
|
|
+
|
|
+ for (EntityType<?> entityType : BuiltInRegistries.ENTITY_TYPE) {
|
|
+ entityType.dabEnabled = true; // reset all, before setting the ones to true
|
|
+ }
|
|
+ get("optimizations.dab.blacklisted-entities",Collections.<String>emptyList(), "A list of entities to ignore for activation")
|
|
+ .forEach(name -> EntityType.byString(name).ifPresentOrElse(entityType -> {
|
|
+ entityType.dabEnabled = false;
|
|
+ }, () -> MinecraftServer.LOGGER.warn("Unknown entity \"" + name + "\"")));
|
|
+
|
|
+ MAIN_CONFIG.setComment("optimizations.dab", "Optimizes entity brains when\n"+"they're far away from the player");
|
|
+ }
|
|
+
|
|
public static void initValues(){
|
|
serverModName = get("misc.server_mod_name",serverModName,"The servermod name will be sent to players,and you can see it in F3 or motd responses");
|
|
fakeVanillaModeEnabled = get("misc.enable_fake_vanilla_mode",fakeVanillaModeEnabled,"Enable this to make the ping response of your server like a vanilla server");
|
|
@@ -130,6 +166,7 @@ public class LuminolConfig {
|
|
initEntityTTL();
|
|
maxProjectileLoadsPerTick = get("optimizations.projectile.max-loads-per-tick", maxProjectileLoadsPerTick, "Controls how many chunks are allowed \nto be sync loaded by projectiles in a tick.");
|
|
maxProjectileLoadsPerProjectile = get("optimizations.projectile.max-loads-per-projectile", maxProjectileLoadsPerProjectile, "Controls how many chunks a projectile \n can load in its lifetime before it gets \nautomatically removed.");
|
|
+ initDAB();
|
|
}
|
|
|
|
public static <T> T get(String key,T def){
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
index ec95159ba13e75ee8fc495307f19b587d3b80cf1..a07694156d3aefc4939581f7cb74009db6528f9a 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
@@ -1003,6 +1003,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
this.timings.entityTick.startTiming(); // Spigot
|
|
profiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.ENTITY_TICK); try { // Folia - profiler
|
|
regionizedWorldData.forEachTickingEntity((entity) -> { // Folia - regionised ticking
|
|
+ entity.activatedPriorityReset = false; // Pufferfish - DAB
|
|
if (!entity.isRemoved()) {
|
|
if (false && this.shouldDiscardEntity(entity)) { // CraftBukkit - We prevent spawning in general, so this butchering is not needed
|
|
entity.discard();
|
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
index 4c7441f4624e71b0689d03b2f8cc39938f69710f..67be79d5b458a30d080a4f68803d20b7b3df4c7f 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
@@ -442,6 +442,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
|
return this.originWorld;
|
|
}
|
|
// Paper end
|
|
+ // Pufferfish start
|
|
+ public boolean activatedPriorityReset = false; // DAB
|
|
+ public int activatedPriority = LuminolConfig.maximumActivationPrio; // golf score
|
|
+ // Pufferfish end
|
|
+
|
|
public float getBukkitYaw() {
|
|
return this.yRot;
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/entity/EntityType.java b/src/main/java/net/minecraft/world/entity/EntityType.java
|
|
index ca7eb18785f13bf4bbbf60acad54f6e00509cb3e..359b2ee9b9f60517cc1051719afb65bde425a563 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/EntityType.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/EntityType.java
|
|
@@ -305,6 +305,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; // Pufferfish
|
|
@Nullable
|
|
private String descriptionId;
|
|
@Nullable
|
|
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
|
index f2526900699319f12aa8efa3da19537296f8897a..0672f9ae2aa22247efde11915cbc3004164d2b30 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
|
@@ -235,10 +235,10 @@ public abstract class Mob extends LivingEntity implements Targeting {
|
|
@Override
|
|
public void inactiveTick() {
|
|
super.inactiveTick();
|
|
- if (this.goalSelector.inactiveTick()) {
|
|
+ if (this.goalSelector.inactiveTick(this.activatedPriority, true)) { // Pufferfish - pass activated priroity
|
|
this.goalSelector.tick();
|
|
}
|
|
- if (this.targetSelector.inactiveTick()) {
|
|
+ if (this.targetSelector.inactiveTick(this.activatedPriority, true)) { // Pufferfish - pass activated priority
|
|
this.targetSelector.tick();
|
|
}
|
|
}
|
|
@@ -935,16 +935,20 @@ public abstract class Mob extends LivingEntity implements Targeting {
|
|
|
|
if (i % 2 != 0 && this.tickCount > 1) {
|
|
this.level().getProfiler().push("targetSelector");
|
|
+ if (this.targetSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking
|
|
this.targetSelector.tickRunningGoals(false);
|
|
this.level().getProfiler().pop();
|
|
this.level().getProfiler().push("goalSelector");
|
|
+ if (this.goalSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking
|
|
this.goalSelector.tickRunningGoals(false);
|
|
this.level().getProfiler().pop();
|
|
} else {
|
|
this.level().getProfiler().push("targetSelector");
|
|
+ if (this.targetSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking
|
|
this.targetSelector.tick();
|
|
this.level().getProfiler().pop();
|
|
this.level().getProfiler().push("goalSelector");
|
|
+ if (this.goalSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking
|
|
this.goalSelector.tick();
|
|
this.level().getProfiler().pop();
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java b/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java
|
|
index b738ee2d3801fadfd09313f05ae24593e56b0ec6..9306ab8d2b6eeb73f86d4d94c0065d461905d702 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java
|
|
@@ -11,6 +11,8 @@ import java.util.Set;
|
|
import java.util.function.Predicate;
|
|
import java.util.function.Supplier;
|
|
import java.util.stream.Stream;
|
|
+
|
|
+import me.earthme.luminol.LuminolConfig;
|
|
import net.minecraft.util.profiling.ProfilerFiller;
|
|
import org.slf4j.Logger;
|
|
|
|
@@ -53,9 +55,12 @@ public class GoalSelector {
|
|
}
|
|
|
|
// Paper start
|
|
- public boolean inactiveTick() {
|
|
+ public boolean inactiveTick(int tickRate, boolean inactive) { // Pufferfish start
|
|
+ if (inactive && !LuminolConfig.dearEnabled) tickRate = 4; // reset to Paper's
|
|
+ tickRate = Math.min(tickRate, this.newGoalRate);
|
|
this.curRate++;
|
|
- return this.curRate % this.newGoalRate == 0;
|
|
+ return this.curRate % tickRate == 0;
|
|
+ // Pufferfish end
|
|
}
|
|
public boolean hasTasks() {
|
|
for (WrappedGoal task : this.availableGoals) {
|
|
diff --git a/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java b/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java
|
|
index 5ad5f22e5aa26445e5eb229958e7bf356bdd460e..d241ca4d0295f9fce39c11197bd435cfac7f6e54 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java
|
|
@@ -221,9 +221,11 @@ public class Allay extends PathfinderMob implements InventoryCarrier, VibrationS
|
|
return 0.4F;
|
|
}
|
|
|
|
+ private int behaviorTick = 0; // Pufferfish
|
|
@Override
|
|
protected void customServerAiStep() {
|
|
this.level().getProfiler().push("allayBrain");
|
|
+ if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish
|
|
this.getBrain().tick((ServerLevel) this.level(), this);
|
|
this.level().getProfiler().pop();
|
|
this.level().getProfiler().push("allayActivityUpdate");
|
|
diff --git a/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java b/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java
|
|
index b21e180641d17438997a80e5bcb0ec7998d24a2e..33c160994f70f71446d665e7487913437c9f9db4 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java
|
|
@@ -275,9 +275,11 @@ public class Axolotl extends Animal implements LerpingModel, VariantHolder<Axolo
|
|
return true;
|
|
}
|
|
|
|
+ private int behaviorTick = 0; // Pufferfish
|
|
@Override
|
|
protected void customServerAiStep() {
|
|
this.level().getProfiler().push("axolotlBrain");
|
|
+ if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish
|
|
this.getBrain().tick((ServerLevel) this.level(), this);
|
|
this.level().getProfiler().pop();
|
|
this.level().getProfiler().push("axolotlActivityUpdate");
|
|
diff --git a/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java b/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java
|
|
index 295769d039f2a1e4f48912a60f9dbe267d8992c1..e88b058c0734e436ef24bab6364b206c13e5a9c2 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java
|
|
@@ -159,9 +159,11 @@ public class Frog extends Animal implements VariantHolder<FrogVariant> {
|
|
|
|
}
|
|
|
|
+ private int behaviorTick = 0; // Pufferfish
|
|
@Override
|
|
protected void customServerAiStep() {
|
|
this.level().getProfiler().push("frogBrain");
|
|
+ if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish
|
|
this.getBrain().tick((ServerLevel)this.level(), this);
|
|
this.level().getProfiler().pop();
|
|
this.level().getProfiler().push("frogActivityUpdate");
|
|
diff --git a/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java b/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java
|
|
index 4aeab90e778629c355189dfe79c39c4b21f5f5ac..6ed4ac06c76b8d0d6e8db778cade15dbd1e3e5f5 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java
|
|
@@ -77,9 +77,11 @@ public class Tadpole extends AbstractFish {
|
|
return SoundEvents.TADPOLE_FLOP;
|
|
}
|
|
|
|
+ private int behaviorTick = 0; // Pufferfish
|
|
@Override
|
|
protected void customServerAiStep() {
|
|
this.level().getProfiler().push("tadpoleBrain");
|
|
+ if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish
|
|
this.getBrain().tick((ServerLevel) this.level(), this);
|
|
this.level().getProfiler().pop();
|
|
this.level().getProfiler().push("tadpoleActivityUpdate");
|
|
diff --git a/src/main/java/net/minecraft/world/entity/animal/goat/Goat.java b/src/main/java/net/minecraft/world/entity/animal/goat/Goat.java
|
|
index 5d247ac38fe8a61603b3d934f3000bcda773142b..2e4177cfb02616ef6fa689f6d378976e39484cfb 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/animal/goat/Goat.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/animal/goat/Goat.java
|
|
@@ -191,9 +191,11 @@ public class Goat extends Animal {
|
|
return (Brain<Goat>) super.getBrain(); // CraftBukkit - decompile error
|
|
}
|
|
|
|
+ private int behaviorTick = 0; // Pufferfish
|
|
@Override
|
|
protected void customServerAiStep() {
|
|
this.level().getProfiler().push("goatBrain");
|
|
+ if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish
|
|
this.getBrain().tick((ServerLevel) this.level(), this);
|
|
this.level().getProfiler().pop();
|
|
this.level().getProfiler().push("goatActivityUpdate");
|
|
diff --git a/src/main/java/net/minecraft/world/entity/monster/hoglin/Hoglin.java b/src/main/java/net/minecraft/world/entity/monster/hoglin/Hoglin.java
|
|
index 01a2016ac82807d28ffe407b7dbb74bdbcde503e..9921b160fb21f72fbd28fe81ea66fbc3dc05f83f 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/monster/hoglin/Hoglin.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/monster/hoglin/Hoglin.java
|
|
@@ -128,9 +128,11 @@ public class Hoglin extends Animal implements Enemy, HoglinBase {
|
|
return (Brain<Hoglin>) super.getBrain(); // Paper - decompile fix
|
|
}
|
|
|
|
+ private int behaviorTick; // Pufferfish
|
|
@Override
|
|
protected void customServerAiStep() {
|
|
this.level().getProfiler().push("hoglinBrain");
|
|
+ if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish
|
|
this.getBrain().tick((ServerLevel)this.level(), this);
|
|
this.level().getProfiler().pop();
|
|
HoglinAi.updateActivity(this);
|
|
diff --git a/src/main/java/net/minecraft/world/entity/monster/piglin/Piglin.java b/src/main/java/net/minecraft/world/entity/monster/piglin/Piglin.java
|
|
index a9813da7f2b248f98f22e0ad2e7842915025ec12..83d83e3f84bb6bd58761671c6cd4c8683545ff4c 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/monster/piglin/Piglin.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/monster/piglin/Piglin.java
|
|
@@ -300,9 +300,11 @@ public class Piglin extends AbstractPiglin implements CrossbowAttackMob, Invento
|
|
return !this.cannotHunt;
|
|
}
|
|
|
|
+ private int behaviorTick; // Pufferfish
|
|
@Override
|
|
protected void customServerAiStep() {
|
|
this.level().getProfiler().push("piglinBrain");
|
|
+ if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish
|
|
this.getBrain().tick((ServerLevel) this.level(), this);
|
|
this.level().getProfiler().pop();
|
|
PiglinAi.updateActivity(this);
|
|
diff --git a/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java b/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java
|
|
index 937f81a859953498abe73bea560c86e6560e1c33..0a151c679b0dc943598180942d6d4b3886211688 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java
|
|
@@ -273,11 +273,13 @@ public class Warden extends Monster implements VibrationSystem {
|
|
|
|
}
|
|
|
|
+ private int behaviorTick = 0; // Pufferfish
|
|
@Override
|
|
protected void customServerAiStep() {
|
|
ServerLevel worldserver = (ServerLevel) this.level();
|
|
|
|
worldserver.getProfiler().push("wardenBrain");
|
|
+ if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish
|
|
this.getBrain().tick(worldserver, this);
|
|
this.level().getProfiler().pop();
|
|
super.customServerAiStep();
|
|
diff --git a/src/main/java/net/minecraft/world/entity/npc/Villager.java b/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
|
index a7857a7d141a552f800d7becd130e0cf1660e886..8a93eaf8dbabb10c67e94986853103f88291f11d 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
|
@@ -142,6 +142,8 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
|
return holder.is(PoiTypes.MEETING);
|
|
});
|
|
|
|
+ public long nextGolemPanic = -1; // Pufferfish
|
|
+
|
|
public Villager(EntityType<? extends Villager> entityType, Level world) {
|
|
this(entityType, world, VillagerType.PLAINS);
|
|
}
|
|
@@ -245,6 +247,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
|
}
|
|
// Spigot End
|
|
|
|
+ private int behaviorTick = 0; // Pufferfish
|
|
@Override
|
|
@Deprecated // Paper
|
|
protected void customServerAiStep() {
|
|
@@ -254,7 +257,11 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
|
protected void customServerAiStep(final boolean inactive) {
|
|
// Paper end
|
|
this.level().getProfiler().push("villagerBrain");
|
|
- if (!inactive) this.getBrain().tick((ServerLevel) this.level(), this); // Paper
|
|
+ // Pufferfish start
|
|
+ if (!inactive && this.behaviorTick++ % this.activatedPriority == 0) {
|
|
+ this.getBrain().tick((ServerLevel) this.level(), this); // Paper
|
|
+ }
|
|
+ // Pufferfish end
|
|
this.level().getProfiler().pop();
|
|
if (this.assignProfessionWhenSpawned) {
|
|
this.assignProfessionWhenSpawned = false;
|
|
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
|
|
index e960c307434736af5a0fff626d6bccf5cd46f35d..1690809e85ad4e65e09097f1db0139137bc335ed 100644
|
|
--- a/src/main/java/org/spigotmc/ActivationRange.java
|
|
+++ b/src/main/java/org/spigotmc/ActivationRange.java
|
|
@@ -1,5 +1,6 @@
|
|
package org.spigotmc;
|
|
|
|
+import me.earthme.luminol.LuminolConfig;
|
|
import net.minecraft.core.BlockPos;
|
|
import net.minecraft.server.MinecraftServer;
|
|
import net.minecraft.server.level.ServerChunkCache;
|
|
@@ -38,6 +39,10 @@ import co.aikar.timings.MinecraftTimings;
|
|
import net.minecraft.world.entity.schedule.Activity;
|
|
import net.minecraft.world.level.Level;
|
|
import net.minecraft.world.phys.AABB;
|
|
+// Pufferfish start
|
|
+import net.minecraft.world.phys.Vec3;
|
|
+import java.util.List;
|
|
+// Pufferfish end
|
|
|
|
public class ActivationRange
|
|
{
|
|
@@ -231,6 +236,25 @@ public class ActivationRange
|
|
}
|
|
// Paper end - Configurable marker ticking
|
|
ActivationRange.activateEntity(entity, bbByType); // Folia - threaded regions
|
|
+
|
|
+ // Pufferfish start
|
|
+ if (LuminolConfig.dearEnabled && entity.getType().dabEnabled) {
|
|
+ if (!entity.activatedPriorityReset) {
|
|
+ entity.activatedPriorityReset = true;
|
|
+ entity.activatedPriority = LuminolConfig.maximumActivationPrio;
|
|
+ }
|
|
+ Vec3 playerVec = player.position();
|
|
+ Vec3 entityVec = entity.position();
|
|
+ double diffX = playerVec.x - entityVec.x, diffY = playerVec.y - entityVec.y, diffZ = playerVec.z - entityVec.z;
|
|
+ int squaredDistance = (int) (diffX * diffX + diffY * diffY + diffZ * diffZ);
|
|
+ entity.activatedPriority = squaredDistance > LuminolConfig.startDistanceSquared ?
|
|
+ Math.max(1, Math.min(squaredDistance >> LuminolConfig.activationDistanceMod, entity.activatedPriority)) :
|
|
+ 1;
|
|
+ } else {
|
|
+ entity.activatedPriority = 1;
|
|
+ }
|
|
+ // Pufferfish end
|
|
+
|
|
}
|
|
// Paper end
|
|
}
|
|
@@ -247,12 +271,12 @@ public class ActivationRange
|
|
if ( io.papermc.paper.threadedregions.RegionizedServer.getCurrentTick() > entity.activatedTick ) // Folia - threaded regions
|
|
{
|
|
if ( entity.defaultActivationState )
|
|
- {
|
|
+ { // Pufferfish - diff on change
|
|
entity.activatedTick = io.papermc.paper.threadedregions.RegionizedServer.getCurrentTick(); // Folia - threaded regions
|
|
return;
|
|
}
|
|
if ( bbByType[entity.activationType.ordinal()].intersects( entity.getBoundingBox() ) ) // Folia - threaded regions
|
|
- {
|
|
+ { // Pufferfish - diff on change
|
|
entity.activatedTick = io.papermc.paper.threadedregions.RegionizedServer.getCurrentTick(); // Folia - threaded regions
|
|
}
|
|
}
|