mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-26 18:39:23 +00:00
Current implementation of OP lock is not an appropriate solution to prevent plugins that contain backdoor or malicious code. There are many ways to bypass this check to manipulate the OP list or permissions. The best way to prevent this kind of grief is to get plugins from valid and trustworthy places.
92 lines
4.7 KiB
Diff
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)) {
|