Skip to content

Commit 2a55e35

Browse files
Option to have default CustomSpawners in custom worlds (#7493)
1 parent b6dad9c commit 2a55e35

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Jake Potrebic <jake.m.potrebic@gmail.com>
3+
Date: Sat, 19 Feb 2022 20:15:41 -0800
4+
Subject: [PATCH] Option to have default CustomSpawners in custom worlds
5+
6+
By default, only LevelStem's that specifically match the ResourceKey for
7+
OVERWORLD will have the 5 (currently) impls of CustomSpawner (for
8+
phantoms, wandering traders, etc.). This adds an option to instead of
9+
just looking at the LevelStem key, look at the DimensionType key which
10+
is one level below that. Defaults to off to keep vanilla behavior.
11+
12+
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
13+
index 153f07bac06093b43a1f5b0f8e1a46ffbe6407e5..a7ebf6d9f79ce50a90c3c903563e00a10607f9f2 100644
14+
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
15+
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
16+
@@ -679,4 +679,9 @@ public class PaperConfig {
17+
}
18+
globalMaxConcurrentChunkLoads = getDouble("settings.chunk-loading.global-max-concurrent-loads", 500.0);
19+
}
20+
+
21+
+ public static boolean useDimensionTypeForCustomSpawners;
22+
+ private static void useDimensionTypeForCustomSpawners() {
23+
+ useDimensionTypeForCustomSpawners = getBoolean("settings.use-dimension-type-for-custom-spawners", false);
24+
+ }
25+
}
26+
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
27+
index 053dbe5eef6574cfe98ab7499181bdd83a81f2e1..6d1d83bc17403346cc9d3143666b927ef55fb9df 100644
28+
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
29+
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
30+
@@ -689,7 +689,15 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
31+
this.commandStorage = new CommandStorage(worldpersistentdata);
32+
} else {
33+
ChunkProgressListener worldloadlistener = this.progressListenerFactory.create(11);
34+
- world = new ServerLevel(this, this.executor, worldSession, iworlddataserver, worldKey, dimensionmanager, worldloadlistener, chunkgenerator, flag, j, ImmutableList.of(), true, org.bukkit.World.Environment.getEnvironment(dimension), gen, biomeProvider);
35+
+ // Paper start - option to use the dimension_type to check if spawners should be added. I imagine mojang will add some datapack-y way of managing this in the future.
36+
+ final List<CustomSpawner> spawners;
37+
+ if (com.destroystokyo.paper.PaperConfig.useDimensionTypeForCustomSpawners && this.registryHolder.registryOrThrow(Registry.DIMENSION_TYPE_REGISTRY).getResourceKey(dimensionmanager).orElseThrow() == DimensionType.OVERWORLD_LOCATION) {
38+
+ spawners = list;
39+
+ } else {
40+
+ spawners = Collections.emptyList();
41+
+ }
42+
+ world = new ServerLevel(this, this.executor, worldSession, iworlddataserver, worldKey, dimensionmanager, worldloadlistener, chunkgenerator, flag, j, spawners, true, org.bukkit.World.Environment.getEnvironment(dimension), gen, biomeProvider);
43+
+ // Paper end
44+
}
45+
46+
worlddata.setModdedInfo(this.getServerModName(), this.getModdedStatus().shouldReportAsModified());

0 commit comments

Comments
 (0)