mirror of
https://github.com/Dreeam-qwq/Gale.git
synced 2025-12-23 08:49:28 +00:00
104 lines
4.9 KiB
Diff
104 lines
4.9 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: AGPL-3.0 (https://www.gnu.org/licenses/agpl-3.0.html)
|
|
Gale - https://galemc.org
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
index 0ed0635ef581705d07934b9b17a63a4c7e19f6e1..650a0f0ada672d050c1d1d52b33fe74dfa1ef5ed 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
@@ -4314,6 +4314,16 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
|
return this.feetBlockState;
|
|
}
|
|
|
|
+ // Gale start - don't load chunks to activate climbing entities
|
|
+ public @Nullable BlockState getFeetBlockStateIfLoaded() {
|
|
+ if (this.feetBlockState == null) {
|
|
+ this.feetBlockState = this.level.getBlockStateIfLoaded(this.blockPosition());
|
|
+ }
|
|
+
|
|
+ return this.feetBlockState;
|
|
+ }
|
|
+ // Gale end - don't load chunks to activate climbing entities
|
|
+
|
|
public ChunkPos chunkPosition() {
|
|
return this.chunkPosition;
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
index 0cc1008b3db93487c8e0801895264683f6d2e439..87499e82e80a8b7d6d8ca6eeaa1819b74fcf1665 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
@@ -1948,19 +1948,43 @@ public abstract class LivingEntity extends Entity {
|
|
|
|
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;
|
|
}
|
|
// 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 blockposition = this.blockPosition();
|
|
- BlockState iblockdata = this.getFeetBlockState();
|
|
+ // Gale start - don't load chunks to activate climbing entities
|
|
+ BlockState iblockdata;
|
|
+ if (loadChunk) {
|
|
+ iblockdata = this.getFeetBlockState();
|
|
+ } else {
|
|
+ iblockdata = this.getFeetBlockStateIfLoaded();
|
|
+ if (iblockdata == null) {
|
|
+ return null;
|
|
+ }
|
|
+ }
|
|
+ // Gale end - don't load chunks to activate climbing entities
|
|
|
|
if (iblockdata.is(BlockTags.CLIMBABLE)) {
|
|
this.lastClimbablePos = Optional.of(blockposition);
|
|
diff --git a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
|
index 75e0128d1f4f5b112f9908373b2e32941c68888e..f611c38cb628569fbf3257e006f410d6f0a25d39 100644
|
|
--- a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
|
+++ b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
|
@@ -287,6 +287,18 @@ public class GaleWorldConfiguration extends ConfigurationPart {
|
|
public boolean toSpawnPhantoms = false;
|
|
// Gale end - MultiPaper - don't load chunks to spawn phantoms
|
|
|
|
+ // Gale start - don't load chunks to activate climbing entities
|
|
+ /**
|
|
+ * Whether to load chunks to check whether entities are on a climbable block. If false,
|
|
+ * entities in unloaded chunks will be assumed to not be on a climbable block.
|
|
+ * <ul>
|
|
+ * <li><i>Default</i>: false</li>
|
|
+ * <li><i>Vanilla</i>: true</li>
|
|
+ * </ul>
|
|
+ */
|
|
+ public boolean toActivateClimbingEntities = false;
|
|
+ // Gale end - don't load chunks to activate climbing entities
|
|
+
|
|
}
|
|
|
|
}
|