9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-19 15:09:25 +00:00
Files
Leaf/leaf-server/minecraft-patches/features/0115-Cache-supporting-block-check.patch
Dreeam 52477a91ae Updated Upstream (Paper/Gale)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
PaperMC/Paper@f4f27551 [ci/skip] Clarify BlockFadeEvent#getNewState javadocs (#12250)
PaperMC/Paper@102c8bbc Add config for updating equipment on player actions (#12275)
PaperMC/Paper@f0388e2f Call EntityPushedByEntityAttackEvent for Mace AoE (#12257)
PaperMC/Paper@c37b890c More deferred requireNonNull message creation
PaperMC/Paper@310f5229 Add unsupported config option and internal API to simplify remote item matching
PaperMC/Paper@6ea42025 Send all attributes on respawn (#12274)
PaperMC/Paper@2d3a1385 [ci/skip] Refine recipe management API documentation. (#12287)
PaperMC/Paper@aaaeb4e1 [ci/skip] Make compilation logs actually readable (#12276)
PaperMC/Paper@bb1beda6 feat: add event to wind charge explode (#12248)

Gale Changes:
Dreeam-qwq/Gale@43bfa513 Updated Upstream (Paper)
Dreeam-qwq/Gale@ab0a7189 Updated Upstream ()
Dreeam-qwq/Gale@27ddb2fa [ci/skip] Added merge announcement
Dreeam-qwq/Gale@523e7745 [ci/skip] Fix announcement format
Dreeam-qwq/Gale@d91ed070 [ci/skip] Update annocement
2025-03-17 14:30:27 -04:00

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 80ad278eac81aac72d6ec7737287ad018eff7c54..9bc978ca290ca772b0367e89b69fe16b502b0cd2 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;
}