161 lines
7.9 KiB
Diff
161 lines
7.9 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 d0c03dc51c8ad4997963b244ada855827a4c4065..99a8b9a8ee2032107be03bbc13d0275a337faf7b 100644
|
|
--- a/net/minecraft/server/level/ChunkMap.java
|
|
+++ b/net/minecraft/server/level/ChunkMap.java
|
|
@@ -1278,7 +1278,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
|
double d1 = vec3_dx * vec3_dx + vec3_dz * vec3_dz; // Paper
|
|
double d2 = d * d;
|
|
// Paper start - Configurable entity tracking range by Y
|
|
- boolean flag = d1 <= d2;
|
|
+ boolean flag = d1 <= d2 && !entity.isCulled(); // Luminol - Ray tracing entity tracker
|
|
if (flag && 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 bf177d9f7e5d9f643d13fcb9ea23686fd0f32dc5..897f42dcaf1f1f300f5cccb1b1180237aab216e3 100644
|
|
--- a/net/minecraft/world/entity/Entity.java
|
|
+++ b/net/minecraft/world/entity/Entity.java
|
|
@@ -140,7 +140,7 @@ import net.minecraft.world.scores.ScoreHolder;
|
|
import net.minecraft.world.scores.Team;
|
|
import org.jetbrains.annotations.Contract;
|
|
|
|
-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
|
|
+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
|
|
// CraftBukkit start
|
|
private static final org.slf4j.Logger LOGGER = com.mojang.logging.LogUtils.getLogger();
|
|
private static final int CURRENT_LEVEL = 2;
|
|
@@ -5955,4 +5955,48 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
return ((ServerLevel) this.level()).isPositionEntityTicking(this.blockPosition());
|
|
}
|
|
// Paper end - Expose entity id counter
|
|
+
|
|
+ public boolean shouldTickHot() { return this.tickCount > 20 * 10 && this.isAlive(); } // KioCG
|
|
+
|
|
+ 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 (!me.earthme.luminol.config.modules.experiment.RayTrackingEntityTrackerConfig.enabled)
|
|
+ return false;
|
|
+ return this.culled;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void setOutOfCamera(boolean value) {
|
|
+ this.outOfCamera = value;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean isOutOfCamera() {
|
|
+ if (!me.earthme.luminol.config.modules.experiment.RayTrackingEntityTrackerConfig.enabled)
|
|
+ return false;
|
|
+ return this.outOfCamera;
|
|
+ }
|
|
+
|
|
}
|
|
diff --git a/net/minecraft/world/entity/EntityType.java b/net/minecraft/world/entity/EntityType.java
|
|
index 6b72ab233508e6df1eca34360ce76d102ee25a41..f39ee4605cc15102d6560afd1dad5f56dd53cf4e 100644
|
|
--- a/net/minecraft/world/entity/EntityType.java
|
|
+++ b/net/minecraft/world/entity/EntityType.java
|
|
@@ -1109,6 +1109,9 @@ public class EntityType<T extends Entity> implements FeatureElement, EntityTypeT
|
|
public final int passengerTickTimerId;
|
|
public final int passengerInactiveTickTimerId;
|
|
// Folia end - profiler
|
|
+ // Luminol - Raytracing entity tracker
|
|
+ public boolean skipRaytracningCheck = false;
|
|
+ // Luminol end
|
|
|
|
public EntityType(
|
|
EntityType.EntityFactory<T> factory,
|
|
diff --git a/net/minecraft/world/entity/player/Player.java b/net/minecraft/world/entity/player/Player.java
|
|
index aed525af488eb839d31d6bec0673b7e128ca4068..5af32286092222f09ad2b54dd2fa6bd9ad3a8f40 100644
|
|
--- a/net/minecraft/world/entity/player/Player.java
|
|
+++ b/net/minecraft/world/entity/player/Player.java
|
|
@@ -220,6 +220,25 @@ public abstract class Player extends LivingEntity {
|
|
return (org.bukkit.craftbukkit.entity.CraftHumanEntity) super.getBukkitEntity();
|
|
}
|
|
// CraftBukkit end
|
|
+ // Luminol start - Raytracing entity tracker
|
|
+ public dev.tr7zw.entityculling.CullTask cullTask;
|
|
+ {
|
|
+ if (!me.earthme.luminol.config.modules.experiment.RayTrackingEntityTrackerConfig.enabled) {
|
|
+ this.cullTask = null;
|
|
+ }else {
|
|
+ final com.logisticscraft.occlusionculling.OcclusionCullingInstance culling = new com.logisticscraft.occlusionculling.OcclusionCullingInstance(
|
|
+ me.earthme.luminol.config.modules.experiment.RayTrackingEntityTrackerConfig.tracingDistance,
|
|
+ new dev.tr7zw.entityculling.DefaultChunkDataProvider(this.level())
|
|
+ );
|
|
+
|
|
+ this.cullTask = new dev.tr7zw.entityculling.CullTask(
|
|
+ culling, this,
|
|
+ me.earthme.luminol.config.modules.experiment.RayTrackingEntityTrackerConfig.hitboxLimit,
|
|
+ me.earthme.luminol.config.modules.experiment.RayTrackingEntityTrackerConfig.checkIntervalMs
|
|
+ );
|
|
+ }
|
|
+ }
|
|
+ // Luminol end
|
|
|
|
public Player(Level level, BlockPos pos, float yRot, GameProfile gameProfile) {
|
|
super(EntityType.PLAYER, level);
|
|
@@ -277,6 +296,26 @@ public abstract class Player extends LivingEntity {
|
|
|
|
@Override
|
|
public void tick() {
|
|
+ // Luminol start - Ray tracing entity tracker
|
|
+ if (!me.earthme.luminol.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(
|
|
+ me.earthme.luminol.config.modules.experiment.RayTrackingEntityTrackerConfig.tracingDistance,
|
|
+ new dev.tr7zw.entityculling.DefaultChunkDataProvider(this.level())
|
|
+ );
|
|
+
|
|
+ this.cullTask = new dev.tr7zw.entityculling.CullTask(
|
|
+ culling, this,
|
|
+ me.earthme.luminol.config.modules.experiment.RayTrackingEntityTrackerConfig.hitboxLimit,
|
|
+ me.earthme.luminol.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);
|
|
@@ -1415,6 +1454,7 @@ public abstract class Player extends LivingEntity {
|
|
if (this.containerMenu != null && this.hasContainerOpen()) {
|
|
this.doCloseContainer();
|
|
}
|
|
+ if (this.cullTask != null) this.cullTask.signalStop(); // Luminol - Ray tracing entity tracker
|
|
}
|
|
|
|
@Override
|