|
| 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 |
0 commit comments