Skip to content

Commit

Permalink
Remove some optimization, disable all optimization by default, rename…
Browse files Browse the repository at this point in the history
… Optimization to Performance
  • Loading branch information
MC-XiaoHei authored Jul 23, 2024
1 parent 1754df3 commit 46d3787
Show file tree
Hide file tree
Showing 26 changed files with 43 additions and 658 deletions.
67 changes: 12 additions & 55 deletions patches/server/0004-Lumina-server-config-and-command.patch
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ index 8302e4bedc03795c4cda526466fa4dc279b2dd21..17351285d16956d22eca0d5dce336699
public EntitySelector(int count, boolean includesNonPlayers, boolean localWorldOnly, Predicate<Entity> basePredicate, MinMaxBounds.Doubles distance, Function<Vec3, Vec3> positionOffset, @Nullable AABB box, BiConsumer<Vec3, List<? extends Entity>> sorter, boolean senderOnly, @Nullable String playerName, @Nullable UUID uuid, @Nullable EntityType<?> type, boolean usesAt) {
this.maxResults = count;
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
index d95c73f589e831f65088d30c4af4d04cbf7e7fd9..dfd750db2df80e84754535b8502a7b0b7c05548c 100644
index f01863e33b7407c14e8bcd2a44e63bed01afe838..a37c35fd271ac815bd67a40ceaca95ff895ffd9e 100644
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
@@ -222,6 +222,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
Expand Down Expand Up @@ -280,7 +280,7 @@ index 0000000000000000000000000000000000000000..3879e94473e6e8499a53d9c89fb6fab7
\ No newline at end of file
diff --git a/src/main/java/org/leavesmc/lumina/config/ConfigModule.java b/src/main/java/org/leavesmc/lumina/config/ConfigModule.java
new file mode 100644
index 0000000000000000000000000000000000000000..fc3bd7f1ad1f1303ad7f6ff284e23828bf5ff18e
index 0000000000000000000000000000000000000000..a4700c541d425a25d0e26e8ef82dcf47b45647c3
--- /dev/null
+++ b/src/main/java/org/leavesmc/lumina/config/ConfigModule.java
@@ -0,0 +1,16 @@
Expand All @@ -289,15 +289,15 @@ index 0000000000000000000000000000000000000000..fc3bd7f1ad1f1303ad7f6ff284e23828
+import org.leavesmc.lumina.config.modules.Fix;
+import org.leavesmc.lumina.config.modules.Gameplay;
+import org.leavesmc.lumina.config.modules.Misc;
+import org.leavesmc.lumina.config.modules.Optimization;
+import org.leavesmc.lumina.config.modules.Performance;
+import org.spongepowered.configurate.objectmapping.ConfigSerializable;
+
+@ConfigSerializable
+public class ConfigModule {
+ public String configVersion = "1";
+ public Fix fix = new Fix();
+ public Gameplay gameplay = new Gameplay();
+ public Optimization optimization = new Optimization();
+ public Performance performance = new Performance();
+ public Misc misc = new Misc();
+}
\ No newline at end of file
Expand Down Expand Up @@ -469,10 +469,10 @@ index 0000000000000000000000000000000000000000..b4eba642ebdcb1dadab0b1085ac94b4c
+}
diff --git a/src/main/java/org/leavesmc/lumina/config/modules/Misc.java b/src/main/java/org/leavesmc/lumina/config/modules/Misc.java
new file mode 100644
index 0000000000000000000000000000000000000000..52ae05a79cb3da8f424b24d20834dc72190510b4
index 0000000000000000000000000000000000000000..4576d68a7a2be5782e527262c20ff24edc9e1b71
--- /dev/null
+++ b/src/main/java/org/leavesmc/lumina/config/modules/Misc.java
@@ -0,0 +1,19 @@
@@ -0,0 +1,20 @@
+package org.leavesmc.lumina.config.modules;
+
+import org.leavesmc.lumina.config.modules.misc.RegionFormatConfig;
Expand All @@ -487,34 +487,30 @@ index 0000000000000000000000000000000000000000..52ae05a79cb3da8f424b24d20834dc72
+ public String serverModName = "Lumina";
+ public boolean fakeVanilla = false;
+ public boolean checkUsername = true;
+ public boolean useAlternativeKeepAlive = true;
+ public boolean saveConfigAfterSet = true;
+ public boolean verifyPublicKeyOnlyInOnlineMode = false;
+ public WatchdogConfig watchdog = new WatchdogConfig();
+ public RegionFormatConfig regionFormat = new RegionFormatConfig();
+}
diff --git a/src/main/java/org/leavesmc/lumina/config/modules/Optimization.java b/src/main/java/org/leavesmc/lumina/config/modules/Optimization.java
diff --git a/src/main/java/org/leavesmc/lumina/config/modules/Performance.java b/src/main/java/org/leavesmc/lumina/config/modules/Performance.java
new file mode 100644
index 0000000000000000000000000000000000000000..e31c590d256d8ee0c847c657846e5cadc2f17574
index 0000000000000000000000000000000000000000..ce1b53b29e5a1b515ecbd7f99804d79518a67bc3
--- /dev/null
+++ b/src/main/java/org/leavesmc/lumina/config/modules/Optimization.java
@@ -0,0 +1,18 @@
+++ b/src/main/java/org/leavesmc/lumina/config/modules/Performance.java
@@ -0,0 +1,13 @@
+package org.leavesmc.lumina.config.modules;
+
+import org.leavesmc.lumina.config.modules.optimization.*;
+import org.spongepowered.configurate.objectmapping.ConfigSerializable;
+
+@ConfigSerializable
+public class Optimization {
+ public AsyncPathProcessingConfig asyncPathProcessing = new AsyncPathProcessingConfig();
+ public EntityDABConfig entityDab = new EntityDABConfig();
+public class Performance {
+ public PetalReduceSensorWorkConfig petalReduceSensorWork = new PetalReduceSensorWorkConfig();
+ public ProjectileChunkReduceConfig projectileChunkReduce = new ProjectileChunkReduceConfig();
+ public boolean entityGoalSelectorInactiveTick = false;
+ public double entityWakeUpDurationRatioStandardDeviation = 0.2;
+ public boolean allowLoadChunksToActiveClimbingEntities = false;
+ public boolean useAlternativeKeepAlive = true;
+ public boolean optimizeSuffocation = false;
+ public boolean reduceEntityFluidLookups = true;
+}
diff --git a/src/main/java/org/leavesmc/lumina/config/modules/fix/FoliaEntityMovingFixConfig.java b/src/main/java/org/leavesmc/lumina/config/modules/fix/FoliaEntityMovingFixConfig.java
new file mode 100644
Expand Down Expand Up @@ -627,45 +623,6 @@ index 0000000000000000000000000000000000000000..12a85414d4eb8f7740c227f5a5fb8514
+ }
+ }
+}
diff --git a/src/main/java/org/leavesmc/lumina/config/modules/optimization/EntityDABConfig.java b/src/main/java/org/leavesmc/lumina/config/modules/optimization/EntityDABConfig.java
new file mode 100644
index 0000000000000000000000000000000000000000..9b29297052562c1464b5d93a0b03a144efadf5ef
--- /dev/null
+++ b/src/main/java/org/leavesmc/lumina/config/modules/optimization/EntityDABConfig.java
@@ -0,0 +1,33 @@
+package org.leavesmc.lumina.config.modules.optimization;
+
+import net.minecraft.core.registries.BuiltInRegistries;
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.world.entity.EntityType;
+import org.spongepowered.configurate.objectmapping.ConfigSerializable;
+import org.spongepowered.configurate.objectmapping.meta.PostProcess;
+
+import java.util.Collections;
+import java.util.List;
+
+@ConfigSerializable
+public class EntityDABConfig {
+ public boolean dearEnabled = false;
+ public int startDistance = 12;
+ public int startDistanceSquared;
+ public int maximumActivationPrio = 20;
+ public int activationDistanceMod;
+ public List<String> blackedEntities = Collections.emptyList();
+
+ @PostProcess
+ public void onLoaded() {
+ for (EntityType<?> entityType : BuiltInRegistries.ENTITY_TYPE) {
+ entityType.dabEnabled = true; // reset all, before setting the ones to true
+ }
+
+ blackedEntities.forEach(name -> EntityType.byString(name).ifPresentOrElse(entityType -> {
+ entityType.dabEnabled = false;
+ }, () -> MinecraftServer.LOGGER.warn("Unknown entity \"" + name + "\"")));
+
+ // config.setComment("optimizations.dab", "Optimizes entity brains when\n" + "they're far away from the player");
+ }
+}
diff --git a/src/main/java/org/leavesmc/lumina/config/modules/optimization/LoadChunksToActiveClimbingEntitiesConfig.java b/src/main/java/org/leavesmc/lumina/config/modules/optimization/LoadChunksToActiveClimbingEntitiesConfig.java
new file mode 100644
index 0000000000000000000000000000000000000000..b72e9c1fe5c7fb9abc9a3230b7339fb73c84e25c
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0012-Petal-Reduce-sensor-work.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Subject: [PATCH] Petal Reduce sensor work


diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
index bb5de770b6659379a68c077ff1cfc8d95d149c5c..611926cc99cf275d7aa596f3b7e86fd6abc18f59 100644
index bb5de770b6659379a68c077ff1cfc8d95d149c5c..9e418d614df14719c1d7826fdf7827492ab05c66 100644
--- a/src/main/java/net/minecraft/world/entity/Mob.java
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
@@ -983,12 +983,12 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Targeti
Expand All @@ -17,7 +17,7 @@ index bb5de770b6659379a68c077ff1cfc8d95d149c5c..611926cc99cf275d7aa596f3b7e86fd6

gameprofilerfiller.push("sensing");
- this.sensing.tick();
+ if (i % org.leavesmc.lumina.config.LuminaConfig.configModule.optimization.petalReduceSensorWork.delayTicks == 0 || !org.leavesmc.lumina.config.LuminaConfig.configModule.optimization.petalReduceSensorWork.enabled) this.sensing.tick(); // Luminol - Petal - Reduce sensor work
+ if (i % org.leavesmc.lumina.config.LuminaConfig.configModule.performance.petalReduceSensorWork.delayTicks == 0 || !org.leavesmc.lumina.config.LuminaConfig.configModule.performance.petalReduceSensorWork.enabled) this.sensing.tick(); // Luminol - Petal - Reduce sensor work
gameprofilerfiller.pop();
- int i = this.tickCount + this.getId();

Expand Down
4 changes: 2 additions & 2 deletions patches/server/0016-Pufferfish-Optimize-suffocation.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Subject: [PATCH] Pufferfish Optimize suffocation


diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index dc290b2bc486fb5cf2bb216e5a8436a5b588fa8d..3215adeea327584dc637276c2b1a8a336241163a 100644
index dc290b2bc486fb5cf2bb216e5a8436a5b588fa8d..f0c7654e6a28620b37ca28420dc1c79a3bd31e51 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -441,7 +441,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
Expand All @@ -30,7 +30,7 @@ index dc290b2bc486fb5cf2bb216e5a8436a5b588fa8d..3215adeea327584dc637276c2b1a8a33
+ }
+
+ public boolean shouldCheckForSuffocation() {
+ return !org.leavesmc.lumina.config.LuminaConfig.configModule.optimization.optimizeSuffocation || (tickCount % 10 == 0 && couldPossiblyBeHurt(1.0F));
+ return !org.leavesmc.lumina.config.LuminaConfig.configModule.performance.optimizeSuffocation || (tickCount % 10 == 0 && couldPossiblyBeHurt(1.0F));
+ }
+ // Pufferfish end
+
Expand Down

This file was deleted.

Loading

0 comments on commit 46d3787

Please sign in to comment.