mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2026-01-04 15:41:40 +00:00
* Fix TE Lag * Sepals Rearrange the attackable conditions * Cache ItemStack max stack size * fix build * extra: Skip dirty stats copy when requesting player stats * extra: Reset dirty flag when loading maps from the disk * extra: Supporting block cache * extra: Avoid useless deque clear on - credit: @MachineBreaker * experimental/draft: Optimize SortedArraySet * experimental/draft: Simplify SortedArraySet - sometime complex stuff doesnt mean faster. * extra: Change maps/sets in brain + remove streams from villagers * extra: Remove 'copyOf' from Baby Villager Sensor * experimental: Rewrite trigger in SimpleCriterionTrigger * [ci/skip] fix comments * Faster setter for SimpleCriterionTrigger * extra: Cache and optimize fluidOnEyes * Sync changes * [ci/skip] cleanup * extra: QuadTree implementation for isChunkNearPlayer * [ci/skip] cleanup * [ci/skip] cleanup * [ci/skip] clean up * [ci/skip] cleanup * Only player pushable * Store chunkPos with keys * [ci/skip] cleanup * [ci/skip] cleanup * cleanup * rebuild patches * cache some more stuff * extra: optimize collectTickingChunks * remove quadTree optimization for now (will open a new PR just for that) * temp: Lazily optimize isChunkNearPlayer * Inline filter & merge as a single loop * [ci/skip] Add diff on change * extra: optimize everything but the testing itself on getEntities * [ci/skip] cleanup * Optimize chunkUnloadQueue * Remove iterators from inventory * [ci/skip] Add TODOs * i hate programming * remove forEach * extra: Alternative Brain Behaviour * remove: opt getEntities + cache fluidOnEyes * extra: Improve checkDespawn - credits: @kidofcubes * extra: Improve pushEntity and getEntities * yeet this * VERY EXPERIMENTAL: getEntities Optimization * fix bunch of issues from getEntities patch * extra: slightly optimize getNearestPlayer - credits: @kidofcubes * drop a patch for now (will open a new pr) * move these to a new branch * fix and optimize checkDespawn patches * Rebuild Patches * [ci/skip] Update benchmark * [ci/skip] cleanup * Drop * [ci/skip] Drop * Rebuild * [ci/skip] * Add configurable brain running behavior cache update interval * Move to new pr * [ci/skip] Update benchmark --------- Co-authored-by: MachineBreaker <saltspigotpp@gmail.com> Co-authored-by: kidofcubes <kidofcubes@gmail.com> Co-authored-by: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
64 lines
2.9 KiB
Diff
64 lines
2.9 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Taiyou06 <kaandindar21@gmail.com>
|
|
Date: Sat, 8 Feb 2025 05:32:30 +0100
|
|
Subject: [PATCH] Cache supporting block check
|
|
|
|
|
|
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
|
index 4544dd876d3cbcdb9b774b4a1f0c4737f3124bc5..6ca446fd9ab38329ba505526a56f8e4f64a9a639 100644
|
|
--- a/net/minecraft/world/entity/Entity.java
|
|
+++ b/net/minecraft/world/entity/Entity.java
|
|
@@ -1083,12 +1083,36 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
return this.mainSupportingBlockPos.isPresent() && this.mainSupportingBlockPos.get().equals(pos);
|
|
}
|
|
|
|
+ // Leaf start - Cache supporting block check
|
|
+ private boolean canSkipSupportingBlockSearch = false;
|
|
+ private BlockState cachedSupportingBlockState = null;
|
|
+ // Leaf end - Cache supporting block check
|
|
+
|
|
protected void checkSupportingBlock(boolean onGround, @Nullable Vec3 movement) {
|
|
+ // Leaf start - Cache supporting block check
|
|
+ // Skip full check if no movement and cache is valid
|
|
+ if (movement == null || (movement.x == 0 && movement.z == 0 && movement.y == 0)) {
|
|
+ if (canSkipSupportingBlockSearch) {
|
|
+ return;
|
|
+ }
|
|
+ } else {
|
|
+ // Invalidate cache on movement
|
|
+ canSkipSupportingBlockSearch = false;
|
|
+ cachedSupportingBlockState = null;
|
|
+ }
|
|
+ // Leaf end - Cache supporting block check
|
|
if (onGround) {
|
|
AABB boundingBox = this.getBoundingBox();
|
|
AABB aabb = new AABB(boundingBox.minX, boundingBox.minY - 1.0E-6, boundingBox.minZ, boundingBox.maxX, boundingBox.minY, boundingBox.maxZ);
|
|
Optional<BlockPos> optional = this.level.findSupportingBlock(this, aabb);
|
|
if (optional.isPresent() || this.onGroundNoBlocks) {
|
|
+ // Leaf start - Cache supporting block check
|
|
+ if (optional.isPresent()) { // Cache the block state if found
|
|
+ BlockPos pos = optional.get();
|
|
+ cachedSupportingBlockState = this.level.getBlockState(pos);
|
|
+ canSkipSupportingBlockSearch = true;
|
|
+ }
|
|
+ // Leaf end - Cache supporting block check
|
|
this.mainSupportingBlockPos = optional;
|
|
} else if (movement != null) {
|
|
AABB aabb1 = aabb.move(-movement.x, 0.0, -movement.z);
|
|
@@ -1105,6 +1129,15 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
}
|
|
}
|
|
|
|
+
|
|
+ // Leaf start - Cache supporting block check
|
|
+ // Helper method to get cached supporting block state
|
|
+ @Nullable
|
|
+ public BlockState getCachedSupportingBlock() {
|
|
+ return canSkipSupportingBlockSearch ? cachedSupportingBlockState : null;
|
|
+ }
|
|
+ // Leaf end - Cache supporting block check
|
|
+
|
|
public boolean onGround() {
|
|
return this.onGround;
|
|
}
|