mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2026-01-03 22:26:19 +00:00
83 lines
3.6 KiB
Diff
83 lines
3.6 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
|
Date: Sun, 25 Dec 2022 19:39:38 +0100
|
|
Subject: [PATCH] Don't load chunks to activate climbing entities
|
|
|
|
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
|
Gale - https://galemc.org
|
|
|
|
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
|
index 466d70b679059bdbe850033547d999c88063d1c2..d85d70fe5bfa63f0b188663d7ea11b56ff265a18 100644
|
|
--- a/net/minecraft/world/entity/Entity.java
|
|
+++ b/net/minecraft/world/entity/Entity.java
|
|
@@ -4644,6 +4644,16 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
return this.inBlockState;
|
|
}
|
|
|
|
+ // 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());
|
|
+ }
|
|
+
|
|
+ return this.inBlockState;
|
|
+ }
|
|
+ // Gale end - don't load chunks to activate climbing entities
|
|
+
|
|
public ChunkPos chunkPosition() {
|
|
return this.chunkPosition;
|
|
}
|
|
diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
|
|
index 6e93836570859929e4f35d23d9dbcc2ebbc8fb27..8d7150fbd296a0b957e9de987d2e49815264a4b2 100644
|
|
--- a/net/minecraft/world/entity/LivingEntity.java
|
|
+++ b/net/minecraft/world/entity/LivingEntity.java
|
|
@@ -2097,8 +2097,17 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
|
|
|
public boolean onClimbableCached() {
|
|
if (!this.blockPosition().equals(this.lastClimbingPosition)) {
|
|
- this.cachedOnClimbable = this.onClimbable();
|
|
- this.lastClimbingPosition = this.blockPosition();
|
|
+ // Gale start - don't load chunks to activate climbing entities
|
|
+ Boolean onClimbableIfLoaded = this.onClimbable(this.level().galeConfig().smallOptimizations.loadChunks.toActivateClimbingEntities);
|
|
+
|
|
+ if (onClimbableIfLoaded != null) {
|
|
+ this.cachedOnClimbable = onClimbableIfLoaded;
|
|
+ this.lastClimbingPosition = this.blockPosition();
|
|
+ } else {
|
|
+ this.cachedOnClimbable = false;
|
|
+ this.lastClimbingPosition = null;
|
|
+ }
|
|
+ // Gale end - don't load chunks to activate climbing entities
|
|
}
|
|
|
|
return this.cachedOnClimbable;
|
|
@@ -2106,11 +2115,28 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
|
// Gale end - Airplane - cache on climbable check
|
|
|
|
public boolean onClimbable() {
|
|
+ // Gale start - don't load chunks to activate climbing entities
|
|
+ return onClimbable(true);
|
|
+ }
|
|
+
|
|
+ public Boolean onClimbable(boolean loadChunk) {
|
|
+ // Gale end - don't load chunks to activate climbing entities
|
|
if (this.isSpectator()) {
|
|
return false;
|
|
} else {
|
|
BlockPos blockPos = this.blockPosition();
|
|
BlockState inBlockState = this.getInBlockState();
|
|
+ // Gale start - don't load chunks to activate climbing entities
|
|
+ if (loadChunk) {
|
|
+ inBlockState = this.getInBlockState();
|
|
+ } else {
|
|
+ inBlockState = this.getInBlockStateIfLoaded();
|
|
+
|
|
+ if (inBlockState == null) {
|
|
+ return null;
|
|
+ }
|
|
+ }
|
|
+ // Gale end - don't load chunks to activate climbing entities
|
|
if (inBlockState.is(BlockTags.CLIMBABLE)) {
|
|
this.lastClimbablePos = Optional.of(blockPos);
|
|
return true;
|