Skip to content

Commit 987294d

Browse files
committed
Add Lophine: Add config to enable Raytracing tracker, Optimize Chicken config
1 parent c17ab62 commit 987294d

File tree

7 files changed

+317
-2
lines changed

7 files changed

+317
-2
lines changed

.gitignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ build
99

1010
/atdeprecated-server/build.gradle.kts
1111
/atdeprecated-server/src/minecraft
12-
atDeprecated-api/build
12+
/atdeprecated-server/build
13+
/atdeprecated-server/.gradle
14+
/atdeprecated-api/build
15+
/atdeprecated-api/build.gradle.kts
1316
/paper-server
1417
/folia-server
1518
/luminol-server
16-
/atDeprecated-api/build.gradle.kts
1719
/paper-api
1820
/paper-api-generator
1921
/folia-api

.gitmodules

Whitespace-only changes.
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: MidnightTale <[email protected]>
3+
Date: Thu, 24 Jul 2025 22:27:33 +0700
4+
Subject: [PATCH] Optimize chicken
5+
6+
7+
diff --git a/net/minecraft/world/entity/animal/Chicken.java b/net/minecraft/world/entity/animal/Chicken.java
8+
index da408c313d898413dee928e9c80501ddf56d75e8..b096a8c71da5b18a8a7a240aba2b43934c1fc7f4 100644
9+
--- a/net/minecraft/world/entity/animal/Chicken.java
10+
+++ b/net/minecraft/world/entity/animal/Chicken.java
11+
@@ -68,20 +68,27 @@ public class Chicken extends Animal {
12+
13+
public Chicken(EntityType<? extends Chicken> entityType, Level level) {
14+
super(entityType, level);
15+
- this.eggTime = this.random.nextInt(6000) + 6000;
16+
+ this.eggTime = this.random.nextInt(fun.mntale.atdeprecated.config.AtCoreConfig.ENTITY_CONFIG.chickenEggLayInterval) + fun.mntale.atdeprecated.config.AtCoreConfig.ENTITY_CONFIG.chickenEggLayInterval; // atDeprecated
17+
this.setPathfindingMalus(PathType.WATER, 0.0F);
18+
}
19+
20+
@Override
21+
protected void registerGoals() {
22+
this.goalSelector.addGoal(0, new FloatGoal(this));
23+
- this.goalSelector.addGoal(1, new PanicGoal(this, 1.4));
24+
+ // atDeprecated start
25+
+ if (!fun.mntale.atdeprecated.config.AtCoreConfig.ENTITY_CONFIG.optimizeChickenBehavior) {
26+
+ this.goalSelector.addGoal(1, new PanicGoal(this, 1.4));
27+
+ }
28+
this.goalSelector.addGoal(2, new BreedGoal(this, 1.0));
29+
this.goalSelector.addGoal(3, new TemptGoal(this, 1.0, itemStack -> itemStack.is(ItemTags.CHICKEN_FOOD), false));
30+
- this.goalSelector.addGoal(4, new FollowParentGoal(this, 1.1));
31+
- this.goalSelector.addGoal(5, new WaterAvoidingRandomStrollGoal(this, 1.0));
32+
- this.goalSelector.addGoal(6, new LookAtPlayerGoal(this, Player.class, 6.0F));
33+
+ if (!fun.mntale.atdeprecated.config.AtCoreConfig.ENTITY_CONFIG.optimizeChickenBehavior) {
34+
+ this.goalSelector.addGoal(4, new FollowParentGoal(this, 1.1));
35+
+ this.goalSelector.addGoal(5, new WaterAvoidingRandomStrollGoal(this, 1.0));
36+
+ this.goalSelector.addGoal(6, new LookAtPlayerGoal(this, Player.class, 6.0F));
37+
+ }
38+
+
39+
this.goalSelector.addGoal(7, new RandomLookAroundGoal(this));
40+
+ // atDeprecated end
41+
}
42+
43+
@Override
44+
@@ -111,16 +118,34 @@ public class Chicken extends Animal {
45+
}
46+
47+
this.flap = this.flap + this.flapping * 2.0F;
48+
- if (this.level() instanceof ServerLevel serverLevel && this.isAlive() && !this.isBaby() && !this.isChickenJockey() && --this.eggTime <= 0) {
49+
- this.forceDrops = true; // CraftBukkit
50+
- if (this.dropFromGiftLootTable(serverLevel, BuiltInLootTables.CHICKEN_LAY, this::spawnAtLocation)) {
51+
- this.playSound(SoundEvents.CHICKEN_EGG, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
52+
- this.gameEvent(GameEvent.ENTITY_PLACE);
53+
+ // atDeprecated start
54+
+ if (fun.mntale.atdeprecated.config.AtCoreConfig.ENTITY_CONFIG.enableChickenEggLaying && this.level() instanceof ServerLevel serverLevel && this.isAlive() && !this.isBaby() && !this.isChickenJockey()) {
55+
+ int checkInterval = fun.mntale.atdeprecated.config.AtCoreConfig.ENTITY_CONFIG.chickenEggLayCheckInterval;
56+
+ if (checkInterval > 0) {
57+
+ if ((this.tickCount + this.getId()) % checkInterval == 0) {
58+
+ if ((this.eggTime -= checkInterval) <= 0) {
59+
+ this.forceDrops = true;
60+
+ if (this.dropFromGiftLootTable(serverLevel, BuiltInLootTables.CHICKEN_LAY, this::spawnAtLocation)) {
61+
+ this.playSound(SoundEvents.CHICKEN_EGG, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
62+
+ this.gameEvent(GameEvent.ENTITY_PLACE);
63+
+ }
64+
+ this.forceDrops = false;
65+
+ this.eggTime = this.random.nextInt(fun.mntale.atdeprecated.config.AtCoreConfig.ENTITY_CONFIG.chickenEggLayInterval) + fun.mntale.atdeprecated.config.AtCoreConfig.ENTITY_CONFIG.chickenEggLayInterval;
66+
+ }
67+
+ }
68+
+ } else {
69+
+ if (--this.eggTime <= 0) {
70+
+ this.forceDrops = true;
71+
+ if (this.dropFromGiftLootTable(serverLevel, BuiltInLootTables.CHICKEN_LAY, this::spawnAtLocation)) {
72+
+ this.playSound(SoundEvents.CHICKEN_EGG, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
73+
+ this.gameEvent(GameEvent.ENTITY_PLACE);
74+
+ }
75+
+ this.forceDrops = false;
76+
+ this.eggTime = this.random.nextInt(fun.mntale.atdeprecated.config.AtCoreConfig.ENTITY_CONFIG.chickenEggLayInterval) + fun.mntale.atdeprecated.config.AtCoreConfig.ENTITY_CONFIG.chickenEggLayInterval;
77+
+ }
78+
}
79+
- this.forceDrops = false; // CraftBukkit
80+
-
81+
- this.eggTime = this.random.nextInt(6000) + 6000;
82+
}
83+
+ // atDeprecated end
84+
}
85+
86+
@Override
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: MidnightTale <[email protected]>
3+
Date: Thu, 24 Jul 2025 23:04:37 +0700
4+
Subject: [PATCH] Lophine: Add config to enable Raytracing tracker
5+
6+
Co-authored by: MrHua269 <[email protected]>
7+
As part of: Purpur (https://github.com/LuminolMC/Lophine/blob/904abaa56499a869259d3e6b3e586c1d33e34d28/lophine-server/minecraft-patches/features/0006-Add-config-to-enable-Raytracing-tracker.patch)
8+
Licensed under: MIT (https://github.com/LuminolMC/Lophine/blob/904abaa56499a869259d3e6b3e586c1d33e34d28/LICENSE.md)
9+
10+
diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java
11+
index 6868b915bf3deb85783a638d4441a15fea6da2dc..d6b5a6fe6c314edf4faba34af0f42908a8709a00 100644
12+
--- a/net/minecraft/server/level/ChunkMap.java
13+
+++ b/net/minecraft/server/level/ChunkMap.java
14+
@@ -1278,7 +1278,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
15+
double d1 = vec3_dx * vec3_dx + vec3_dz * vec3_dz; // Paper
16+
double d2 = d * d;
17+
// Paper start - Configurable entity tracking range by Y
18+
- boolean flag = d1 <= d2;
19+
+ boolean flag = d1 <= d2 && !entity.isCulled(); // Luminol - Ray tracing entity tracker // atDeprecated - Ray tracing entity tracker
20+
if (flag && level.paperConfig().entities.trackingRangeY.enabled) {
21+
double rangeY = level.paperConfig().entities.trackingRangeY.get(this.entity, -1);
22+
if (rangeY != -1) {
23+
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
24+
index dc3d29b7d1590ba366755fef51e4254d901d0da8..90084f1d999adc805e009096d3ca785b22fe8318 100644
25+
--- a/net/minecraft/world/entity/Entity.java
26+
+++ b/net/minecraft/world/entity/Entity.java
27+
@@ -147,7 +147,7 @@ import net.minecraft.world.waypoints.WaypointTransmitter;
28+
import org.jetbrains.annotations.Contract;
29+
import org.slf4j.Logger;
30+
31+
-public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess, ScoreHolder, DataComponentGetter, ca.spottedleaf.moonrise.patches.chunk_system.entity.ChunkSystemEntity, ca.spottedleaf.moonrise.patches.entity_tracker.EntityTrackerEntity { // Paper - rewrite chunk system // Paper - optimise entity tracker
32+
+public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess, ScoreHolder, DataComponentGetter, ca.spottedleaf.moonrise.patches.chunk_system.entity.ChunkSystemEntity, ca.spottedleaf.moonrise.patches.entity_tracker.EntityTrackerEntity, dev.tr7zw.entityculling.versionless.access.Cullable { // Paper - rewrite chunk system // Paper - optimise entity tracker // Luminol - Ray tracing entity tracker // atDeprecated - Ray tracing entity tracker
33+
// CraftBukkit start
34+
private static final int CURRENT_LEVEL = 2;
35+
public boolean preserveMotion = true; // Paper - Fix Entity Teleportation and cancel velocity if teleported; keep initial motion on first snapTo
36+
@@ -6352,4 +6352,47 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
37+
// Paper end - Expose entity id counter
38+
39+
public boolean shouldTickHot() { return this.tickCount > 20 * 10 && this.isAlive(); } // KioCG
40+
+
41+
+ // Luminol - Ray tracing entity tracker // atDeprecated - Ray tracing entity tracker
42+
+ private long lasttime = 0;
43+
+ private boolean culled = false;
44+
+ private boolean outOfCamera = false;
45+
+
46+
+ @Override
47+
+ public void setTimeout() {
48+
+ this.lasttime = System.currentTimeMillis() + 1000;
49+
+ }
50+
+
51+
+ @Override
52+
+ public boolean isForcedVisible() {
53+
+ return this.lasttime > System.currentTimeMillis();
54+
+ }
55+
+
56+
+ @Override
57+
+ public void setCulled(boolean value) {
58+
+ this.culled = value;
59+
+ if (!value) {
60+
+ setTimeout();
61+
+ }
62+
+ }
63+
+
64+
+ @Override
65+
+ public boolean isCulled() {
66+
+ if (!fun.mntale.atdeprecated.config.AtCoreConfig.RAY_TRACKING_ENTITY_TRACKER_CONFIG.enabled)
67+
+ return false;
68+
+ return this.culled;
69+
+ }
70+
+
71+
+ @Override
72+
+ public void setOutOfCamera(boolean value) {
73+
+ this.outOfCamera = value;
74+
+ }
75+
+
76+
+ @Override
77+
+ public boolean isOutOfCamera() {
78+
+ if (!fun.mntale.atdeprecated.config.AtCoreConfig.RAY_TRACKING_ENTITY_TRACKER_CONFIG.enabled)
79+
+ return false;
80+
+ return this.outOfCamera;
81+
+ }
82+
+ // atDeprecated end
83+
}
84+
diff --git a/net/minecraft/world/entity/EntityType.java b/net/minecraft/world/entity/EntityType.java
85+
index 6f00ffa05d9597917574357e0069c9b056aa5ce2..af0a8b99188f25adb0a76e227d3debc189293690 100644
86+
--- a/net/minecraft/world/entity/EntityType.java
87+
+++ b/net/minecraft/world/entity/EntityType.java
88+
@@ -1119,6 +1119,9 @@ public class EntityType<T extends Entity> implements FeatureElement, EntityTypeT
89+
public final int passengerTickTimerId;
90+
public final int passengerInactiveTickTimerId;
91+
// Folia end - profiler
92+
+ // Luminol - Raytracing entity tracker // atDeprecated - Raytracing entity tracker
93+
+ public boolean skipRaytracningCheck = false;
94+
+ // Luminol end // atDeprecated - Raytracing entity tracker
95+
96+
public EntityType(
97+
EntityType.EntityFactory<T> factory,
98+
diff --git a/net/minecraft/world/entity/player/Player.java b/net/minecraft/world/entity/player/Player.java
99+
index b9b14cd9f0ff5556e076aab21f4c2b85d1e48ee5..4480b491250f08350f479c27d17d51fe62bc60f6 100644
100+
--- a/net/minecraft/world/entity/player/Player.java
101+
+++ b/net/minecraft/world/entity/player/Player.java
102+
@@ -230,6 +230,25 @@ public abstract class Player extends LivingEntity {
103+
return (org.bukkit.craftbukkit.entity.CraftHumanEntity) super.getBukkitEntity();
104+
}
105+
// CraftBukkit end
106+
+ // Luminol start - Raytracing entity tracker // atDeprecated - Raytracing entity tracker
107+
+ public dev.tr7zw.entityculling.CullTask cullTask;
108+
+ {
109+
+ if (!fun.mntale.atdeprecated.config.AtCoreConfig.RAY_TRACKING_ENTITY_TRACKER_CONFIG.enabled) {
110+
+ this.cullTask = null;
111+
+ }else {
112+
+ final com.logisticscraft.occlusionculling.OcclusionCullingInstance culling = new com.logisticscraft.occlusionculling.OcclusionCullingInstance(
113+
+ fun.mntale.atdeprecated.config.AtCoreConfig.RAY_TRACKING_ENTITY_TRACKER_CONFIG.tracingDistance,
114+
+ new dev.tr7zw.entityculling.DefaultChunkDataProvider(this.level())
115+
+ );
116+
+
117+
+ this.cullTask = new dev.tr7zw.entityculling.CullTask(
118+
+ culling, this,
119+
+ fun.mntale.atdeprecated.config.AtCoreConfig.RAY_TRACKING_ENTITY_TRACKER_CONFIG.hitboxLimit,
120+
+ fun.mntale.atdeprecated.config.AtCoreConfig.RAY_TRACKING_ENTITY_TRACKER_CONFIG.checkIntervalMs
121+
+ );
122+
+ }
123+
+ }
124+
+ // Luminol end // atDeprecated - Raytracing entity tracker
125+
126+
public Player(Level level, GameProfile gameProfile) {
127+
super(EntityType.PLAYER, level);
128+
@@ -288,6 +307,26 @@ public abstract class Player extends LivingEntity {
129+
130+
@Override
131+
public void tick() {
132+
+ // Luminol start - Ray tracing entity tracker // atDeprecated - Ray tracing entity tracker
133+
+ if (!fun.mntale.atdeprecated.config.AtCoreConfig.RAY_TRACKING_ENTITY_TRACKER_CONFIG.enabled) {
134+
+ if (this.cullTask != null) this.cullTask.signalStop();
135+
+ this.cullTask = null;
136+
+ }else {
137+
+ final com.logisticscraft.occlusionculling.OcclusionCullingInstance culling = new com.logisticscraft.occlusionculling.OcclusionCullingInstance(
138+
+ fun.mntale.atdeprecated.config.AtCoreConfig.RAY_TRACKING_ENTITY_TRACKER_CONFIG.tracingDistance,
139+
+ new dev.tr7zw.entityculling.DefaultChunkDataProvider(this.level())
140+
+ );
141+
+
142+
+ this.cullTask = new dev.tr7zw.entityculling.CullTask(
143+
+ culling, this,
144+
+ fun.mntale.atdeprecated.config.AtCoreConfig.RAY_TRACKING_ENTITY_TRACKER_CONFIG.hitboxLimit,
145+
+ fun.mntale.atdeprecated.config.AtCoreConfig.RAY_TRACKING_ENTITY_TRACKER_CONFIG.checkIntervalMs
146+
+ );
147+
+ }
148+
+ if (this.cullTask != null) this.cullTask.setup();
149+
+ if (this.cullTask != null) this.cullTask.requestCullSignal(); // Luminol - Ray tracing entity tracker // atDeprecated - Ray tracing entity tracker
150+
+ // Luminol end // atDeprecated - Ray tracing entity tracker
151+
+
152+
this.noPhysics = this.isSpectator();
153+
if (this.isSpectator() || this.isPassenger()) {
154+
this.setOnGround(false);
155+
@@ -574,6 +613,7 @@ public abstract class Player extends LivingEntity {
156+
}
157+
158+
protected void doCloseContainer() {
159+
+ if (this.cullTask != null) this.cullTask.signalStop(); // Luminol - Ray tracing entity tracker // atDeprecated - Ray tracing entity tracker
160+
}
161+
162+
@Override

atdeprecated-server/src/main/java/fun/mntale/atdeprecated/config/AtCoreConfig.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import fun.mntale.atdeprecated.config.modules.features.*;
44
import fun.mntale.atdeprecated.config.modules.fixes.*;
55
import fun.mntale.atdeprecated.config.modules.experiment.*;
6+
import fun.mntale.atdeprecated.config.modules.optimizations.EntityConfig;
67
import fun.mntale.atdeprecated.config.modules.removed.RemovedConfig;
78
import java.io.File;
89

@@ -18,6 +19,8 @@ public class AtCoreConfig {
1819
public static final InventoryConfig INVENTORY_CONFIG = new InventoryConfig();
1920
public static final WaypointConfig WAYPOINT_CONFIG = new WaypointConfig();
2021
public static final RemovedConfig REMOVED_CONFIG = new RemovedConfig();
22+
public static final EntityConfig ENTITY_CONFIG = new EntityConfig();
23+
public static final RayTrackingEntityTrackerConfig RAY_TRACKING_ENTITY_TRACKER_CONFIG = new RayTrackingEntityTrackerConfig();
2124

2225
public static void init() {
2326
registerModules();
@@ -38,5 +41,7 @@ private static void registerModules() {
3841
configManager.registerModule(INVENTORY_CONFIG);
3942
configManager.registerModule(WAYPOINT_CONFIG);
4043
configManager.registerModule(REMOVED_CONFIG);
44+
configManager.registerModule(ENTITY_CONFIG);
45+
configManager.registerModule(RAY_TRACKING_ENTITY_TRACKER_CONFIG);
4146
}
4247
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package fun.mntale.atdeprecated.config.modules.experiment;
2+
3+
import fun.mntale.atdeprecated.config.EnumConfigCategory;
4+
import fun.mntale.atdeprecated.config.IConfigModule;
5+
import fun.mntale.atdeprecated.config.annotations.ConfigInfo;
6+
7+
public class RayTrackingEntityTrackerConfig implements IConfigModule {
8+
9+
@ConfigInfo(name = "enabled", comments = "Enable this to use ray-tracing to cull entities.")
10+
public boolean enabled = true;
11+
12+
@ConfigInfo(name = "tracing-distance", comments = "The distance to trace for entities.")
13+
public int tracingDistance = 64;
14+
15+
@ConfigInfo(name = "hitbox-limit", comments = "The maximum number of hitboxes to check.")
16+
public int hitboxLimit = 1000;
17+
18+
@ConfigInfo(name = "check-interval-ms", comments = "The interval in milliseconds to check for culling.")
19+
public int checkIntervalMs = 500;
20+
21+
@Override
22+
public EnumConfigCategory getCategory() {
23+
return EnumConfigCategory.EXPERIMENT;
24+
}
25+
26+
@Override
27+
public String getBaseName() {
28+
return "ray-tracking-entity-tracker";
29+
}
30+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package fun.mntale.atdeprecated.config.modules.optimizations;
2+
3+
import fun.mntale.atdeprecated.config.EnumConfigCategory;
4+
import fun.mntale.atdeprecated.config.IConfigModule;
5+
import fun.mntale.atdeprecated.config.annotations.ConfigInfo;
6+
7+
public class EntityConfig implements IConfigModule {
8+
9+
@ConfigInfo(name = "optimize-chicken-behavior", comments = "Enable this to optimize chicken behavior by removing complex actions like wandering, looking at players, or panicking.")
10+
public boolean optimizeChickenBehavior = true;
11+
12+
@ConfigInfo(name = "chicken-egg-lay-interval", comments = "The interval in ticks for how often a chicken checks to lay an egg.")
13+
public int chickenEggLayInterval = 36000; // 30 minutes
14+
15+
@ConfigInfo(name = "enable-chicken-egg-laying", comments = "Enable this to allow chickens to lay eggs.")
16+
public boolean enableChickenEggLaying = true;
17+
18+
@ConfigInfo(name = "chicken-egg-lay-check-interval", comments = "The interval in ticks for how often the server checks if a chicken can lay an egg. Set to 0 to check every tick. Higher values are better for performance.")
19+
public int chickenEggLayCheckInterval = 3600; // 3 minutes
20+
21+
@Override
22+
public EnumConfigCategory getCategory() {
23+
return EnumConfigCategory.OPTIMIZATIONS;
24+
}
25+
26+
@Override
27+
public String getBaseName() {
28+
return "entity";
29+
}
30+
}

0 commit comments

Comments
 (0)