mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-19 15:09:25 +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 e7c9b51a115d975ea4a6aaa8e051ac7daf58395e..430dec39410c4445326488b537dcd103715b16f4 100644
|
|
--- a/net/minecraft/world/entity/Entity.java
|
|
+++ b/net/minecraft/world/entity/Entity.java
|
|
@@ -4665,6 +4665,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 a542e1dfa41ec2ea1a979dc27d0155d5c08fd7cc..ed96755b15e9a9d3dc05ccc8afc730437fe035ff 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;
|