105 lines
4.6 KiB
Diff
105 lines
4.6 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: MrHua269 <novau233@163.com>
|
|
Date: Wed, 7 Feb 2024 06:03:02 +0000
|
|
Subject: [PATCH] Gale Don't load chunks to activate climbing entities
|
|
|
|
|
|
diff --git a/src/main/java/me/earthme/luminol/config/modules/optimizations/LoadChunksToActiveClimbingEntitiesConfig.java b/src/main/java/me/earthme/luminol/config/modules/optimizations/LoadChunksToActiveClimbingEntitiesConfig.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..ed62d25d6cd6dfcf8c5db20ced36eb3d3c79dafd
|
|
--- /dev/null
|
|
+++ b/src/main/java/me/earthme/luminol/config/modules/optimizations/LoadChunksToActiveClimbingEntitiesConfig.java
|
|
@@ -0,0 +1,20 @@
|
|
+package me.earthme.luminol.config.modules.optimizations;
|
|
+
|
|
+import me.earthme.luminol.config.ConfigInfo;
|
|
+import me.earthme.luminol.config.EnumConfigCategory;
|
|
+import me.earthme.luminol.config.IConfigModule;
|
|
+
|
|
+public class LoadChunksToActiveClimbingEntitiesConfig implements IConfigModule {
|
|
+ @ConfigInfo(baseName = "allow")
|
|
+ public static boolean allow = false;
|
|
+
|
|
+ @Override
|
|
+ public EnumConfigCategory getCategory() {
|
|
+ return EnumConfigCategory.OPTIMIZATIONS;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public String getBaseName() {
|
|
+ return "load_chunks_to_active_climbing_entities";
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
index f61ac02037ce13bb80b0db0814145fd9ff39bc37..0d8dd2d9b038f0694c955e649f7a4ad0039a3d89 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
@@ -5438,6 +5438,16 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
|
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 e304407868a109ea9455112b2003c89d62db1607..aea521bd240db699eabcbe110d9a25b1141d3634 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
@@ -2033,19 +2033,43 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
|
|
|
public boolean onClimableCached() {
|
|
if (!this.blockPosition().equals(this.lastClimbingPosition)) {
|
|
- this.cachedOnClimable = this.onClimbable();
|
|
- this.lastClimbingPosition = this.blockPosition();
|
|
+ // Gale start - don't load chunks to activate climbing entities
|
|
+ Boolean onClimbableIfLoaded = this.onClimbable(me.earthme.luminol.config.modules.optimizations.LoadChunksToActiveClimbingEntitiesConfig.allow);
|
|
+ if (onClimbableIfLoaded != null) {
|
|
+ this.cachedOnClimable = onClimbableIfLoaded;
|
|
+ this.lastClimbingPosition = this.blockPosition();
|
|
+ } else {
|
|
+ this.cachedOnClimable = false;
|
|
+ this.lastClimbingPosition = null;
|
|
+ }
|
|
+ // Gale end - don't load chunks to activate climbing entities
|
|
}
|
|
return this.cachedOnClimable;
|
|
}
|
|
// Pufferfish end
|
|
|
|
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);
|