mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-19 15:09:25 +00:00
optimize getEntityStatus
This commit is contained in:
@@ -0,0 +1,63 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: hayanesuru <hayanesuru@outlook.jp>
|
||||||
|
Date: Fri, 23 May 2025 15:57:42 +0900
|
||||||
|
Subject: [PATCH] optimize getEntityStatus
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/EntityLookup.java b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/EntityLookup.java
|
||||||
|
index 7554c109c35397bc1a43dd80e87764fd78645bbf..151476fd036839a416c226599279d0d8bf79717b 100644
|
||||||
|
--- a/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/EntityLookup.java
|
||||||
|
+++ b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/EntityLookup.java
|
||||||
|
@@ -93,8 +93,14 @@ public abstract class EntityLookup implements LevelEntityGetter<Entity> {
|
||||||
|
if (entity == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
- final Visibility visibility = EntityLookup.getEntityStatus(entity);
|
||||||
|
- return visibility.isAccessible() ? entity : null;
|
||||||
|
+ // Leaf start
|
||||||
|
+ final FullChunkStatus entityStatus = ((ChunkSystemEntity) entity).moonrise$getChunkStatus();
|
||||||
|
+ return switch (entityStatus) {
|
||||||
|
+ case INACCESSIBLE -> null;
|
||||||
|
+ case FULL, BLOCK_TICKING, ENTITY_TICKING -> entity;
|
||||||
|
+ case null -> null;
|
||||||
|
+ };
|
||||||
|
+ // Leaf end
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@@ -394,7 +400,14 @@ public abstract class EntityLookup implements LevelEntityGetter<Entity> {
|
||||||
|
return Visibility.TICKING;
|
||||||
|
}
|
||||||
|
final FullChunkStatus entityStatus = ((ChunkSystemEntity)entity).moonrise$getChunkStatus();
|
||||||
|
- return Visibility.fromFullChunkStatus(entityStatus == null ? FullChunkStatus.INACCESSIBLE : entityStatus);
|
||||||
|
+ // Leaf start
|
||||||
|
+ return switch (entityStatus) {
|
||||||
|
+ case INACCESSIBLE -> Visibility.HIDDEN;
|
||||||
|
+ case FULL, BLOCK_TICKING -> Visibility.TRACKED;
|
||||||
|
+ case ENTITY_TICKING -> Visibility.TICKING;
|
||||||
|
+ case null -> Visibility.HIDDEN;
|
||||||
|
+ };
|
||||||
|
+ // Leaf end
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean addEntity(final Entity entity, final boolean fromDisk, final boolean event) {
|
||||||
|
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||||
|
index df23d80d6b18e900414aa02e5c1812f0a10f0fb7..9f581d5bdc3f658694bbd8c80abbce4e27e568d3 100644
|
||||||
|
--- a/net/minecraft/world/entity/Entity.java
|
||||||
|
+++ b/net/minecraft/world/entity/Entity.java
|
||||||
|
@@ -381,6 +381,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||||
|
// Paper end
|
||||||
|
// Paper start - rewrite chunk system
|
||||||
|
private final boolean isHardColliding = this.moonrise$isHardCollidingUncached();
|
||||||
|
+ @org.jetbrains.annotations.Nullable // Leaf
|
||||||
|
private net.minecraft.server.level.FullChunkStatus chunkStatus;
|
||||||
|
private ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkData chunkData;
|
||||||
|
private int sectionX = Integer.MIN_VALUE;
|
||||||
|
@@ -394,6 +395,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
+ @org.jetbrains.annotations.Nullable // Leaf
|
||||||
|
public final net.minecraft.server.level.FullChunkStatus moonrise$getChunkStatus() {
|
||||||
|
return this.chunkStatus;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user