Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dontEnableIfInWater option to DAB #144

Merged
merged 9 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions patches/server/0008-Pufferfish-Dynamic-Activation-of-Brain.patch
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,10 @@ index 71a3eadd2f1e00fa066dbfe9918d749d43435a18..03513d3b6118ac5d0a58788462dcbc98
}
diff --git a/src/main/java/org/dreeam/leaf/config/modules/opt/DynamicActivationofBrain.java b/src/main/java/org/dreeam/leaf/config/modules/opt/DynamicActivationofBrain.java
new file mode 100644
index 0000000000000000000000000000000000000000..ed8496e344284f79ff66c1d216090a218d95c311
index 0000000000000000000000000000000000000000..a2e60c43074df560eb01f150bf52b8d0f5af9b54
--- /dev/null
+++ b/src/main/java/org/dreeam/leaf/config/modules/opt/DynamicActivationofBrain.java
@@ -0,0 +1,67 @@
@@ -0,0 +1,71 @@
+package org.dreeam.leaf.config.modules.opt;
+
+import net.minecraft.core.registries.BuiltInRegistries;
Expand All @@ -322,6 +322,7 @@ index 0000000000000000000000000000000000000000..ed8496e344284f79ff66c1d216090a21
+ public static int startDistanceSquared;
+ public static int maximumActivationPrio = 20;
+ public static int activationDistanceMod = 8;
+ public static boolean dontEnableIfInWater = false;
+ public static List<String> blackedEntities = new ArrayList<>();
+
+ @Override
Expand All @@ -331,6 +332,9 @@ index 0000000000000000000000000000000000000000..ed8496e344284f79ff66c1d216090a21
+ they're far away from the player""");
+
+ enabled = config.getBoolean(getBasePath() + ".enabled", enabled);
+ dontEnableIfInWater = config.getBoolean(getBasePath() + ".dont-enable-if-in-water", dontEnableIfInWater, """
+ After enabling this, non-aquatic entities in the water will not be affected by DAB.
+ This could fix entities suffocate in the water.""");
+ startDistance = config.getInt(getBasePath() + ".start-distance", startDistance, """
+ This value determines how far away an entity has to be
+ from the player to start being effected by DEAR.""");
Expand Down Expand Up @@ -367,16 +371,25 @@ index 0000000000000000000000000000000000000000..ed8496e344284f79ff66c1d216090a21
+ }
+}
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
index 0b2f2fbe462ed628ef3d640824d4162e79279089..456f64fcae7a12ca141d8061f69797e58efa1899 100644
index 0b2f2fbe462ed628ef3d640824d4162e79279089..e469b2782932275caa4bb760eefff82916c47d3a 100644
--- a/src/main/java/org/spigotmc/ActivationRange.java
+++ b/src/main/java/org/spigotmc/ActivationRange.java
@@ -238,6 +238,25 @@ public class ActivationRange
@@ -38,7 +38,6 @@ import co.aikar.timings.MinecraftTimings;
import net.minecraft.world.entity.schedule.Activity;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.AABB;
-import org.galemc.gale.configuration.GaleGlobalConfiguration;
import org.galemc.gale.configuration.GaleWorldConfiguration;

public class ActivationRange
@@ -238,6 +237,26 @@ public class ActivationRange
}
// Paper end - Configurable marker ticking
ActivationRange.activateEntity(entity);
+
+ // Pufferfish start
+ if (org.dreeam.leaf.config.modules.opt.DynamicActivationofBrain.enabled && entity.getType().dabEnabled) {
+ if (org.dreeam.leaf.config.modules.opt.DynamicActivationofBrain.enabled && entity.getType().dabEnabled &&
+ (!org.dreeam.leaf.config.modules.opt.DynamicActivationofBrain.dontEnableIfInWater || entity.getType().is(net.minecraft.tags.EntityTypeTags.CAN_BREATHE_UNDER_WATER) || !entity.isInWaterOrBubble())) { // Leaf - Option for dontEnableIfInWater
+ if (!entity.activatedPriorityReset) {
+ entity.activatedPriorityReset = true;
+ entity.activatedPriority = org.dreeam.leaf.config.modules.opt.DynamicActivationofBrain.maximumActivationPrio;
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0011-Purpur-Server-Changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -24824,10 +24824,10 @@ index 0000000000000000000000000000000000000000..129acb8ad139decc6b1c023cb10bc32d
+ // Paper end - lifecycle events
+}
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
index 456f64fcae7a12ca141d8061f69797e58efa1899..530c5d656b6b362d0df85a897d7e8d0497250680 100644
index e469b2782932275caa4bb760eefff82916c47d3a..92a8d0a44a3e8b955807fc6b94564b6660bd94ad 100644
--- a/src/main/java/org/spigotmc/ActivationRange.java
+++ b/src/main/java/org/spigotmc/ActivationRange.java
@@ -216,6 +216,8 @@ public class ActivationRange
@@ -215,6 +215,8 @@ public class ActivationRange
continue;
}

Expand Down
4 changes: 2 additions & 2 deletions patches/server/0015-Remove-Timings.patch
Original file line number Diff line number Diff line change
Expand Up @@ -1838,7 +1838,7 @@ index 579c2e69d8f6ce8398eb1297d1d1ead98c9068a5..00000000000000000000000000000000
-
-}
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
index 530c5d656b6b362d0df85a897d7e8d0497250680..7fd2a463e9208635bd2d9f0b1a4291d60c5dedf2 100644
index 92a8d0a44a3e8b955807fc6b94564b6660bd94ad..dae16e2c3cc0f154dbe3a62e3050548fb649c3c2 100644
--- a/src/main/java/org/spigotmc/ActivationRange.java
+++ b/src/main/java/org/spigotmc/ActivationRange.java
@@ -34,7 +34,6 @@ import net.minecraft.world.entity.projectile.FireworkRocketEntity;
Expand All @@ -1849,7 +1849,7 @@ index 530c5d656b6b362d0df85a897d7e8d0497250680..7fd2a463e9208635bd2d9f0b1a4291d6
import net.minecraft.world.entity.schedule.Activity;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.AABB;
@@ -182,7 +181,6 @@ public class ActivationRange
@@ -181,7 +180,6 @@ public class ActivationRange
*/
public static void activateEntities(Level world)
{
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0124-Optimize-Entity-distanceToSqr.patch
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
Date: Tue, 29 Oct 2077 00:00:00 +0800
Date: Fri, 29 Oct 2077 00:00:00 +0800
Subject: [PATCH] Optimize Entity distanceToSqr

This patch optimizes Entity#distanceToSqr call by using Math#fma which is around 1.2x to 4x faster than original method on CPUs support Fused Multiply-Add (FMA) operation,
This patch optimizes Entity#distanceToSqr call by using Math#fma which is around 1.2x to 4x faster than original method,
avoids multiple casting in Entity#distanceTo, using Math#hypot instead of Mojang's Mth#sqrt. Additionally, this patch makes
these methods more able to be inlined by the JIT compiler.

Expand Down