9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-27 19:09:22 +00:00
Files
Leaf/leaf-server/minecraft-patches/features/0291-optimize-onClimbable.patch
Dreeam f5b95a6716 Updated Upstream (Paper)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
PaperMC/Paper@b0da38c2 Repository details in RuntimeException for MavenLibraryResolver#addRepository (#12939)
PaperMC/Paper@1922be90 Update custom tags (#12183)
PaperMC/Paper@79cf1353 Ignore HopperInventorySearchEvent when it has no listeners (#13009)
PaperMC/Paper@ea014f7a feat: add stuckEntityPoiRetryDelay config (#12949)
PaperMC/Paper@a9e76749 Support for showNotification in PlayerRecipeDiscoverEvent (#12992)
PaperMC/Paper@5622c9dd Expose attribute sentiment (#12974)
PaperMC/Paper@42b653b1 Expose more argument types (#12665)
PaperMC/Paper@52d9a221 [ci/skip] Fix typo in Display javadoc (#13010)
PaperMC/Paper@614e9acf Improve APIs around riptide tridents (#12996)
PaperMC/Paper@51706e5a Fixed DyeItem sheep dye hunk
2025-08-25 15:52:00 -04:00

92 lines
4.7 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: hayanesuru <hayanesuru@outlook.jp>
Date: Sat, 9 Aug 2025 15:42:48 +0900
Subject: [PATCH] optimize onClimbable
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index d61761dc1683e439af4ebfc393bc8c70de23340f..85789dfd30fe4f3b1108634e84b10f168bf6f64e 100644
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -4992,7 +4992,8 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
// Gale start - don't load chunks to activate climbing entities
public @Nullable BlockState getInBlockStateIfLoaded() {
if (this.inBlockState == null) {
- this.inBlockState = this.level.getBlockStateIfLoaded(this.blockPosition());
+ BlockPos pos = this.blockPosition(); // Leaf - optimize onClimbable
+ this.inBlockState = this.level.getBlockStateIfLoadedUnchecked(pos.getX(), pos.getY(), pos.getZ()); // Leaf - optimize onClimbable
}
return this.inBlockState;
diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
index e2f532433df740926ddfb44b6f65299d42241bff..b37f04f395cae15dd249c36235f0c29953febf26 100644
--- a/net/minecraft/world/entity/LivingEntity.java
+++ b/net/minecraft/world/entity/LivingEntity.java
@@ -2217,10 +2217,10 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
public boolean onClimbableCached() {
if (!this.blockPosition().equals(this.lastClimbingPosition)) {
// Gale start - don't load chunks to activate climbing entities
- Boolean onClimbableIfLoaded = this.onClimbable(this.level().galeConfig().smallOptimizations.loadChunks.toActivateClimbingEntities);
+ int onClimbableIfLoaded = this.onClimbable1(this.level().galeConfig().smallOptimizations.loadChunks.toActivateClimbingEntities); // Leaf - optimize onClimbable
- if (onClimbableIfLoaded != null) {
- this.cachedOnClimbable = onClimbableIfLoaded;
+ if (onClimbableIfLoaded != 2) { // Leaf - optimize onClimbable
+ this.cachedOnClimbable = onClimbableIfLoaded == 1; // Leaf - optimize onClimbable
this.lastClimbingPosition = this.blockPosition();
} else {
this.cachedOnClimbable = false;
@@ -2235,35 +2235,39 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
public boolean onClimbable() {
// Gale start - don't load chunks to activate climbing entities
- return onClimbable(true);
+ return onClimbable1(true) == 1; // Leaf - optimize onClimbable
}
- public Boolean onClimbable(boolean loadChunk) {
+ // Leaf start - optimize onClimbable
+ public int onClimbable1(boolean loadChunk) {
// Gale end - don't load chunks to activate climbing entities
if (this.isSpectator()) {
- return false;
+ return 0;
} else {
BlockPos blockPos = this.blockPosition();
// Gale start - don't load chunks to activate climbing
- BlockState inBlockState;
+ BlockState inBlockState = this.getInBlockStateIfLoaded();
if (loadChunk) {
- inBlockState = this.getInBlockState();
- } else {
- inBlockState = this.getInBlockStateIfLoaded();
- if (inBlockState == null) return null;
+ if (inBlockState == null) {
+ inBlockState = this.getInBlockState();
+ }
+ } else if (inBlockState == null) {
+ return 2;
}
// Gale end - don't load chunks to activate climbing entities
- if (inBlockState.is(BlockTags.CLIMBABLE)) {
+ final int flags = inBlockState.tagFlag;
+ if ((flags & org.dreeam.leaf.util.BlockMasks.CLIMBABLE_TAG) != 0) {
this.lastClimbablePos = Optional.of(blockPos);
- return true;
- } else if (inBlockState.getBlock() instanceof TrapDoorBlock && this.trapdoorUsableAsLadder(blockPos, inBlockState)) {
+ return 1;
+ } else if ((flags & org.dreeam.leaf.util.BlockMasks.TRAP_DOOR_CL) != 0 && this.trapdoorUsableAsLadder(blockPos, inBlockState)) {
this.lastClimbablePos = Optional.of(blockPos);
- return true;
+ return 1;
} else {
- return false;
+ return 0;
}
}
}
+ // Leaf end - optimize onClimbable
private boolean trapdoorUsableAsLadder(BlockPos pos, BlockState state) {
if (!state.getValue(TrapDoorBlock.OPEN)) {