mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-19 15:09:25 +00:00
64 lines
3.2 KiB
Diff
64 lines
3.2 KiB
Diff
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..8ae35834bb35ace0bf0ad2c79a80500cbcb19cad 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 - optimize getEntityStatus
|
|
+ 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 - optimize getEntityStatus
|
|
}
|
|
|
|
@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 - optimize getEntityStatus
|
|
+ return switch (entityStatus) {
|
|
+ case INACCESSIBLE -> Visibility.HIDDEN;
|
|
+ case FULL, BLOCK_TICKING -> Visibility.TRACKED;
|
|
+ case ENTITY_TICKING -> Visibility.TICKING;
|
|
+ case null -> Visibility.HIDDEN;
|
|
+ };
|
|
+ // Leaf end - optimize getEntityStatus
|
|
}
|
|
|
|
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 64f24d3e0ecb91e0b4df6229354aeac549234f1b..5ea5ff08c8e22b8a4aeef06ab0fc7a60255c27ee 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 - optimize getEntityStatus
|
|
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 - optimize getEntityStatus
|
|
public final net.minecraft.server.level.FullChunkStatus moonrise$getChunkStatus() {
|
|
return this.chunkStatus;
|
|
}
|