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 163999d50213e0167eb09f0eae883388849f28fa..5196431f52e81608a5575f8a262cd5c855b06182 100644
|
|
--- a/net/minecraft/server/level/ChunkMap.java
|
|
+++ b/net/minecraft/server/level/ChunkMap.java
|
|
@@ -1351,7 +1351,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 43e07a3c98e80f874f55411beac39e215ffdc3cf..cddf44f5da5cba5603dcff4913b4658dcfcc48db 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) {
|
|
@@ -6590,4 +6590,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 31619890f1bd4f458b6f9a31fac8cefaafe09e8e..50643bd0b546a1ff70031ea39e2610f219ef8a79 100644
|
|
--- a/net/minecraft/world/entity/EntityType.java
|
|
+++ b/net/minecraft/world/entity/EntityType.java
|
|
@@ -85,6 +85,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
|