9
0
mirror of https://github.com/Dreeam-qwq/Gale.git synced 2025-12-23 16:59:23 +00:00

Don't load chunks to spawn phantoms

This commit is contained in:
Martijn Muijsers
2022-12-25 19:32:58 +01:00
parent a307b3e06f
commit c9e3715737
22 changed files with 65 additions and 2 deletions

View File

@@ -0,0 +1,63 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Sun, 25 Dec 2022 19:31:09 +0100
Subject: [PATCH] Don't load chunks to spawn phantoms
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
Gale - https://galemc.org
This patch is based on the following patch:
"Don't load chunks when spawning phantoms"
By: PureGero <puregero@gmail.com>
As part of: MultiPaper (https://github.com/MultiPaper/MultiPaper)
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
diff --git a/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java b/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java
index 1c3718d9244513d9fc795dceb564a81375734557..20249e200781daf072ee24102aba69124ca3128a 100644
--- a/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java
+++ b/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java
@@ -73,7 +73,15 @@ public class PhantomSpawner implements CustomSpawner {
if (randomsource.nextInt(j) >= world.paperConfig().entities.behavior.playerInsomniaStartTicks) { // Paper
BlockPos blockposition1 = blockposition.above(20 + randomsource.nextInt(15)).east(-10 + randomsource.nextInt(21)).south(-10 + randomsource.nextInt(21));
- BlockState iblockdata = world.getBlockState(blockposition1);
+ // Gale start - MultiPaper - don't load chunks to spawn phantoms
+ BlockState iblockdata;
+ if (world.galeConfig().smallOptimizations.loadChunks.toSpawnPhantoms) {
+ iblockdata = world.getBlockState(blockposition1);
+ } else {
+ iblockdata = world.getBlockStateIfLoaded(blockposition1);
+ if (iblockdata == null) continue;
+ }
+ // Gale end - MultiPaper - don't load chunks to spawn phantoms
FluidState fluid = world.getFluidState(blockposition1);
if (NaturalSpawner.isValidEmptySpawnBlock(world, blockposition1, iblockdata, fluid, EntityType.PHANTOM)) {
diff --git a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
index c45f4b9d06956a58b4e59afe70203ee8abbfccee..5b5fb89408b201bc3f73cf3dd80a5f8856b48b68 100644
--- a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
+++ b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
@@ -258,6 +258,23 @@ public class GaleWorldConfiguration extends ConfigurationPart {
}
+ public LoadChunks loadChunks;
+ public class LoadChunks extends ConfigurationPart {
+
+ // Gale start - MultiPaper - don't load chunks to spawn phantoms
+ /**
+ * Whether to load chunks to spawn phantoms. If false,
+ * attempts to spawn a phantom in unloaded chunks will do nothing.
+ * <ul>
+ * <li><i>Default</i>: false</li>
+ * <li><i>Vanilla</i>: true</li>
+ * </ul>
+ */
+ public boolean toSpawnPhantoms = false;
+ // Gale end - MultiPaper - don't load chunks to spawn phantoms
+
+ }
+
}
public GameplayMechanics gameplayMechanics;

View File

@@ -36,10 +36,10 @@ index 216929c838446c3c14d9b9906ffa625ef35fcbc8..29c7f53a4fa88a77c4076a6294e689e4
} else {
this.wantedX = vec3.x;
diff --git a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
index c45f4b9d06956a58b4e59afe70203ee8abbfccee..b02eeb68002ed802714ade7a89fecc249d95375b 100644
index 5b5fb89408b201bc3f73cf3dd80a5f8856b48b68..c68f384067059bb5ab92a268daffa3e406123cd7 100644
--- a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
+++ b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
@@ -264,6 +264,7 @@ public class GaleWorldConfiguration extends ConfigurationPart {
@@ -281,6 +281,7 @@ public class GaleWorldConfiguration extends ConfigurationPart {
public class GameplayMechanics extends ConfigurationPart.Post {
public boolean entitiesCanEatBlocksInNonTickingChunks = false; // Gale - Purpur - prevent entities eating blocks in non-ticking chunks