163 lines
7.8 KiB
Diff
163 lines
7.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: MrHua269 <wangxyper@163.com>
|
|
Date: Wed, 5 Feb 2025 15:22:19 +0800
|
|
Subject: [PATCH] Add config to enable raytracing tracker
|
|
|
|
|
|
diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java
|
|
index 8afac579c755df001c91b66b207a45d331629d10..e9cd960a0733ac37fac8e956ae36628bf42b79f2 100644
|
|
--- a/net/minecraft/server/level/ChunkMap.java
|
|
+++ b/net/minecraft/server/level/ChunkMap.java
|
|
@@ -1350,7 +1350,7 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP
|
|
double distanceSquared = deltaToPlayerX * deltaToPlayerX + deltaToPlayerZ * deltaToPlayerZ; // Paper
|
|
double rangeSquared = visibleRange * visibleRange;
|
|
// Paper start - Configurable entity tracking range by Y
|
|
- boolean visibleToPlayer = distanceSquared <= rangeSquared;
|
|
+ boolean visibleToPlayer = distanceSquared <= rangeSquared && !entity.isCulled(); // Luminol - Ray tracing entity tracker
|
|
if (visibleToPlayer && level.paperConfig().entities.trackingRangeY.enabled) {
|
|
double rangeY = level.paperConfig().entities.trackingRangeY.get(this.entity, -1);
|
|
if (rangeY != -1) {
|
|
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
|
index be6d31fc790ff6346ae2aedcd21a43be9d2360c1..cc47f02936cad38627c2ee87e54aa8b80a66a8af 100644
|
|
--- a/net/minecraft/world/entity/Entity.java
|
|
+++ b/net/minecraft/world/entity/Entity.java
|
|
@@ -164,7 +164,7 @@ public abstract class Entity
|
|
ItemOwner,
|
|
SlotProvider,
|
|
DebugValueSource,
|
|
- TypedInstance<EntityType<?>>, ca.spottedleaf.moonrise.patches.chunk_system.entity.ChunkSystemEntity, ca.spottedleaf.moonrise.patches.entity_tracker.EntityTrackerEntity { // Paper - rewrite chunk system // Paper - optimise entity tracker
|
|
+ TypedInstance<EntityType<?>>, 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
|
|
// CraftBukkit start
|
|
private static final int CURRENT_LEVEL = 2;
|
|
static boolean isLevelAtLeast(ValueInput input, int level) {
|
|
@@ -6504,4 +6504,48 @@ public abstract class Entity
|
|
// Paper end
|
|
|
|
public boolean shouldTickHot() { return this.tickCount > 20 * 10 && this.isAlive(); } // KioCG
|
|
+ // Lophine start - Add config to enable raytracing tracker
|
|
+
|
|
+ private long lasttime = 0;
|
|
+ private boolean culled = false;
|
|
+ private boolean outOfCamera = false;
|
|
+
|
|
+ @Override
|
|
+ public void setTimeout() {
|
|
+ this.lasttime = System.currentTimeMillis() + 1000;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean isForcedVisible() {
|
|
+ return this.lasttime > System.currentTimeMillis();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void setCulled(boolean value) {
|
|
+ this.culled = value;
|
|
+ if (!value) {
|
|
+ setTimeout();
|
|
+ }
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean isCulled() {
|
|
+ if (!fun.bm.lophine.config.modules.experiment.RayTrackingEntityTrackerConfig.enabled)
|
|
+ return false;
|
|
+ return this.culled;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void setOutOfCamera(boolean value) {
|
|
+ this.outOfCamera = value;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean isOutOfCamera() {
|
|
+ if (!fun.bm.lophine.config.modules.experiment.RayTrackingEntityTrackerConfig.enabled)
|
|
+ return false;
|
|
+ return this.outOfCamera;
|
|
+ }
|
|
+
|
|
+ // Lophine end - Add config to enable raytracing tracker
|
|
}
|
|
diff --git a/net/minecraft/world/entity/EntityType.java b/net/minecraft/world/entity/EntityType.java
|
|
index 6efaa78faca15c7a48bdffb24480d1bac29f3ba8..8a328a41673a3d720f0b1a5de8ce049e360fac1b 100644
|
|
--- a/net/minecraft/world/entity/EntityType.java
|
|
+++ b/net/minecraft/world/entity/EntityType.java
|
|
@@ -84,6 +84,11 @@ public class EntityType<T extends Entity> implements EntityTypeTest<Entity, T>,
|
|
public final int passengerTickTimerId;
|
|
public final int passengerInactiveTickTimerId;
|
|
// Folia end - profiler
|
|
+ // Lophine start - Add config to enable raytracing tracker
|
|
+ // Luminol - Raytracing entity tracker
|
|
+ public boolean skipRaytracningCheck = false;
|
|
+ // Luminol end
|
|
+ // Lophine end - Add config to enable raytracing tracker
|
|
|
|
public EntityType(
|
|
final EntityType.EntityFactory<T> factory,
|
|
diff --git a/net/minecraft/world/entity/player/Player.java b/net/minecraft/world/entity/player/Player.java
|
|
index 9fdc8134fdde2cdd7724a459a29e51f4ad943403..c6fa9dff800b1491b1e0fc5d7e1dc16b99b8c7db 100644
|
|
--- a/net/minecraft/world/entity/player/Player.java
|
|
+++ b/net/minecraft/world/entity/player/Player.java
|
|
@@ -186,6 +186,25 @@ public abstract class Player extends Avatar implements ContainerUser {
|
|
return (org.bukkit.craftbukkit.entity.CraftHumanEntity) super.getBukkitEntity();
|
|
}
|
|
// CraftBukkit end
|
|
+ // Luminol start - Raytracing entity tracker
|
|
+ public dev.tr7zw.entityculling.CullTask cullTask;
|
|
+ {
|
|
+ if (!fun.bm.lophine.config.modules.experiment.RayTrackingEntityTrackerConfig.enabled) {
|
|
+ this.cullTask = null;
|
|
+ }else {
|
|
+ final com.logisticscraft.occlusionculling.OcclusionCullingInstance culling = new com.logisticscraft.occlusionculling.OcclusionCullingInstance(
|
|
+ fun.bm.lophine.config.modules.experiment.RayTrackingEntityTrackerConfig.tracingDistance,
|
|
+ new dev.tr7zw.entityculling.DefaultChunkDataProvider(this.level())
|
|
+ );
|
|
+
|
|
+ this.cullTask = new dev.tr7zw.entityculling.CullTask(
|
|
+ culling, this,
|
|
+ fun.bm.lophine.config.modules.experiment.RayTrackingEntityTrackerConfig.hitboxLimit,
|
|
+ fun.bm.lophine.config.modules.experiment.RayTrackingEntityTrackerConfig.checkIntervalMs
|
|
+ );
|
|
+ }
|
|
+ }
|
|
+ // Luminol end
|
|
|
|
public Player(final Level level, final GameProfile gameProfile) {
|
|
super(EntityTypes.PLAYER, level);
|
|
@@ -245,6 +264,26 @@ public abstract class Player extends Avatar implements ContainerUser {
|
|
|
|
@Override
|
|
public void tick() {
|
|
+ // Luminol start - Ray tracing entity tracker
|
|
+ if (!fun.bm.lophine.config.modules.experiment.RayTrackingEntityTrackerConfig.enabled) {
|
|
+ if (this.cullTask != null) this.cullTask.signalStop();
|
|
+ this.cullTask = null;
|
|
+ }else {
|
|
+ final com.logisticscraft.occlusionculling.OcclusionCullingInstance culling = new com.logisticscraft.occlusionculling.OcclusionCullingInstance(
|
|
+ fun.bm.lophine.config.modules.experiment.RayTrackingEntityTrackerConfig.tracingDistance,
|
|
+ new dev.tr7zw.entityculling.DefaultChunkDataProvider(this.level())
|
|
+ );
|
|
+
|
|
+ this.cullTask = new dev.tr7zw.entityculling.CullTask(
|
|
+ culling, this,
|
|
+ fun.bm.lophine.config.modules.experiment.RayTrackingEntityTrackerConfig.hitboxLimit,
|
|
+ fun.bm.lophine.config.modules.experiment.RayTrackingEntityTrackerConfig.checkIntervalMs
|
|
+ );
|
|
+ }
|
|
+ if (this.cullTask != null) this.cullTask.setup();
|
|
+ if (this.cullTask != null) this.cullTask.requestCullSignal(); // Luminol - Ray tracing entity tracker
|
|
+ // Luminol end
|
|
+
|
|
this.noPhysics = this.isSpectator();
|
|
if (this.isSpectator() || this.isPassenger()) {
|
|
this.setOnGround(false);
|
|
@@ -1378,6 +1417,7 @@ public abstract class Player extends Avatar implements ContainerUser {
|
|
if (this.hasContainerOpen()) {
|
|
this.doCloseContainer();
|
|
}
|
|
+ if (this.cullTask != null) this.cullTask.signalStop(); // Luminol - Ray tracing entity tracker
|
|
}
|
|
|
|
@Override
|