2022-02-22 18:44:06 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								From: Jake Potrebic <jake.m.potrebic@gmail.com>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Date: Sat, 19 Feb 2022 20:15:41 -0800
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Subject: [PATCH] Option to have default CustomSpawners in custom worlds
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								By default, only LevelStem's that specifically match the ResourceKey for
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								OVERWORLD will have the 5 (currently) impls of CustomSpawner (for
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								phantoms, wandering traders, etc.). This adds an option to instead of
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								just looking at the LevelStem key, look at the DimensionType key which
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								is one level below that. Defaults to off to keep vanilla behavior.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								@@ -0,0 +0,0 @@ public class PaperConfig {
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								         globalMaxConcurrentChunkLoads = getDouble("settings.chunk-loading.global-max-concurrent-loads", 500.0);
							 
						 
					
						
							
								
									
										
										
										
											2022-03-31 06:04:23 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								         playerMaxChunkLoadRate = getDouble("settings.chunk-loading.player-max-chunk-load-rate", -1.0);
							 
						 
					
						
							
								
									
										
										
										
											2022-02-22 18:44:06 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								     }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								+
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								+    public static boolean useDimensionTypeForCustomSpawners;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								+    private static void useDimensionTypeForCustomSpawners() {
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								+        useDimensionTypeForCustomSpawners = getBoolean("settings.use-dimension-type-for-custom-spawners", false);
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								+    }
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								--- a/src/main/java/net/minecraft/server/MinecraftServer.java
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								@@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                 this.commandStorage = new CommandStorage(worldpersistentdata);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								             } else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                 ChunkProgressListener worldloadlistener = this.progressListenerFactory.create(11);
							 
						 
					
						
							
								
									
										
										
										
											2022-02-28 22:43:03 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								-                world = new ServerLevel(this, this.executor, worldSession, iworlddataserver, worldKey, holder, worldloadlistener, chunkgenerator, flag, j, ImmutableList.of(), true, org.bukkit.World.Environment.getEnvironment(dimension), gen, biomeProvider);
 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-22 18:44:06 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								+                // 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.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								+                final List<CustomSpawner> spawners;
 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-28 22:43:03 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								+                if (com.destroystokyo.paper.PaperConfig.useDimensionTypeForCustomSpawners && this.registryHolder.registryOrThrow(Registry.DIMENSION_TYPE_REGISTRY).getResourceKey(holder.value()).orElseThrow() == DimensionType.OVERWORLD_LOCATION) {
 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-22 18:44:06 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								+                    spawners = list;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								+                } else {
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								+                    spawners = Collections.emptyList();
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								+                }
 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-28 22:43:03 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								+                world = new ServerLevel(this, this.executor, worldSession, iworlddataserver, worldKey, holder, worldloadlistener, chunkgenerator, flag, j, spawners, true, org.bukkit.World.Environment.getEnvironment(dimension), gen, biomeProvider);
 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-22 18:44:06 -08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								+                // Paper end
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								             }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								             worlddata.setModdedInfo(this.getServerModName(), this.getModdedStatus().shouldReportAsModified());