mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-21 02:17:42 +01:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: 7232d8f2a EntityLoadCrossbowEvent#shouldConsumeItem 4740bd6c8 Mark PlayerInventory#getItem as nullable bd9ace578 Add a config option to limit the number of entities of each type to load/save in a chunk (#4792) 6bafeb5a9 Move logic from last patch into correct place 9668118fd disable entity ticking flag after watchdog obliteration
143 lines
7.9 KiB
Diff
143 lines
7.9 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: jmp <jasonpenilla2@me.com>
|
|
Date: Sat, 22 Aug 2020 20:47:11 -0700
|
|
Subject: [PATCH] Allow toggling special MobSpawners per world
|
|
|
|
In vanilla, these are all hardcoded on for world type 0 (overworld) and hardcoded off for every other world type. Default config behaviour matches this.
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/MobSpawnerTrader.java b/src/main/java/net/minecraft/server/MobSpawnerTrader.java
|
|
index 8d89f51182444852062d549d23c00a93e601eb38..072ec40f751b19c2a78dfcc6e439c64358d864d3 100644
|
|
--- a/src/main/java/net/minecraft/server/MobSpawnerTrader.java
|
|
+++ b/src/main/java/net/minecraft/server/MobSpawnerTrader.java
|
|
@@ -132,7 +132,17 @@ public class MobSpawnerTrader implements MobSpawner {
|
|
int k = blockposition.getX() + this.a.nextInt(i * 2) - i;
|
|
int l = blockposition.getZ() + this.a.nextInt(i * 2) - i;
|
|
int i1 = iworldreader.a(HeightMap.Type.WORLD_SURFACE, k, l);
|
|
- BlockPosition blockposition2 = new BlockPosition(k, i1, l);
|
|
+ // Purpur start - allow traders to spawn below nether roof
|
|
+ BlockPosition.MutableBlockPosition blockposition2 = new BlockPosition.MutableBlockPosition(k, i1, l);
|
|
+ if (iworldreader.getDimensionManager().hasCeiling()) {
|
|
+ do {
|
|
+ blockposition2.c(EnumDirection.DOWN);
|
|
+ } while (!iworldreader.getType(blockposition2).isAir());
|
|
+ do {
|
|
+ blockposition2.c(EnumDirection.DOWN);
|
|
+ } while (iworldreader.getType(blockposition2).isAir() && blockposition2.getY() > 0);
|
|
+ }
|
|
+ // Purpur end
|
|
|
|
if (SpawnerCreature.a(EntityPositionTypes.Surface.ON_GROUND, iworldreader, blockposition2, EntityTypes.WANDERING_TRADER)) {
|
|
blockposition1 = blockposition2;
|
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
|
index cf1f4fe5832781df7d0bdd5eb24eff8539691c30..aa1b037c0103552761b81318f1d2ad8215bd0370 100644
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
|
@@ -156,7 +156,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
|
|
this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((WorldDataServer) worlddatamutable).getName()); // Spigot
|
|
this.paperConfig = new com.destroystokyo.paper.PaperWorldConfig(((WorldDataServer) worlddatamutable).getName(), this.spigotConfig); // Paper
|
|
this.tuinityConfig = new com.tuinity.tuinity.config.TuinityConfig.WorldConfig(((WorldDataServer)worlddatamutable).getName()); // Tuinity - Server Config
|
|
- this.purpurConfig = new net.pl3x.purpur.PurpurWorldConfig((((WorldDataServer)worlddatamutable).getName())); // Purpur
|
|
+ this.purpurConfig = new net.pl3x.purpur.PurpurWorldConfig(((WorldDataServer) worlddatamutable).getName(), env); // Purpur
|
|
this.chunkPacketBlockController = this.paperConfig.antiXray ? new ChunkPacketBlockControllerAntiXray(this, executor) : ChunkPacketBlockController.NO_OPERATION_INSTANCE; // Paper - Anti-Xray
|
|
this.generator = gen;
|
|
this.world = new CraftWorld((WorldServer) this, gen, env);
|
|
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
|
|
index d06c47484ea073695f8135a42c7985bfbafd6b9c..4fa3d50b4f9f2623ca9265db9afb9a36548b5753 100644
|
|
--- a/src/main/java/net/minecraft/server/WorldServer.java
|
|
+++ b/src/main/java/net/minecraft/server/WorldServer.java
|
|
@@ -339,7 +339,24 @@ public class WorldServer extends World implements GeneratorAccessSeed {
|
|
this.L = new ObjectLinkedOpenHashSet();
|
|
this.Q = flag1;
|
|
this.server = minecraftserver;
|
|
- this.mobSpawners = list;
|
|
+ // Purpur start - enable/disable MobSpawners per world
|
|
+ this.mobSpawners = new java.util.ArrayList<>();
|
|
+ if (purpurConfig.phantomSpawning) {
|
|
+ mobSpawners.add(new MobSpawnerPhantom());
|
|
+ }
|
|
+ if (purpurConfig.patrolSpawning) {
|
|
+ mobSpawners.add(new MobSpawnerPatrol());
|
|
+ }
|
|
+ if (purpurConfig.catSpawning) {
|
|
+ mobSpawners.add(new MobSpawnerCat());
|
|
+ }
|
|
+ if (purpurConfig.villageSiegeSpawning) {
|
|
+ mobSpawners.add(new VillageSiege());
|
|
+ }
|
|
+ if (purpurConfig.villagerTraderSpawning) {
|
|
+ mobSpawners.add(new MobSpawnerTrader(iworlddataserver));
|
|
+ }
|
|
+ // Purpur end
|
|
// CraftBukkit start
|
|
this.worldDataServer = (WorldDataServer) iworlddataserver;
|
|
worldDataServer.world = this;
|
|
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
index 6c50bcc45a4208b1709290944d57793e6f47dcd4..b0a0c6cc6b781130cbfd02edc6c5b511090099c0 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
@@ -7,6 +7,8 @@ import net.minecraft.server.IRegistry;
|
|
import net.minecraft.server.Item;
|
|
import net.minecraft.server.Items;
|
|
import net.minecraft.server.MinecraftKey;
|
|
+import org.apache.commons.lang.BooleanUtils;
|
|
+import org.bukkit.World.Environment;
|
|
import org.bukkit.configuration.ConfigurationSection;
|
|
|
|
import java.util.ArrayList;
|
|
@@ -15,6 +17,7 @@ import java.util.HashSet;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Set;
|
|
+import java.util.function.Predicate;
|
|
import java.util.logging.Level;
|
|
|
|
import static net.pl3x.purpur.PurpurConfig.log;
|
|
@@ -22,9 +25,11 @@ import static net.pl3x.purpur.PurpurConfig.log;
|
|
public class PurpurWorldConfig {
|
|
|
|
private final String worldName;
|
|
+ private final Environment environment;
|
|
|
|
- public PurpurWorldConfig(String worldName) {
|
|
+ public PurpurWorldConfig(String worldName, Environment environment) {
|
|
this.worldName = worldName;
|
|
+ this.environment = environment;
|
|
init();
|
|
}
|
|
|
|
@@ -52,6 +57,12 @@ public class PurpurWorldConfig {
|
|
return PurpurConfig.config.getBoolean("world-settings." + worldName + "." + path, PurpurConfig.config.getBoolean("world-settings.default." + path));
|
|
}
|
|
|
|
+ private boolean getBoolean(String path, Predicate<Boolean> predicate) {
|
|
+ String val = getString(path, "default").toLowerCase();
|
|
+ Boolean bool = BooleanUtils.toBooleanObject(val, "true", "false", "default");
|
|
+ return predicate.test(bool);
|
|
+ }
|
|
+
|
|
private double getDouble(String path, double def) {
|
|
PurpurConfig.config.addDefault("world-settings.default." + path, def);
|
|
return PurpurConfig.config.getDouble("world-settings." + worldName + "." + path, PurpurConfig.config.getDouble("world-settings.default." + path));
|
|
@@ -155,6 +166,21 @@ public class PurpurWorldConfig {
|
|
voidDamageHeight = getDouble("gameplay-mechanics.void-damage-height", voidDamageHeight);
|
|
}
|
|
|
|
+ public boolean catSpawning;
|
|
+ public boolean patrolSpawning;
|
|
+ public boolean phantomSpawning;
|
|
+ public boolean villagerTraderSpawning;
|
|
+ public boolean villageSiegeSpawning;
|
|
+ private void mobSpawnerSettings() {
|
|
+ // values of "default" or null will default to true only if the world environment is normal (aka overworld)
|
|
+ Predicate<Boolean> predicate = (bool) -> (bool != null && bool) || (bool == null && environment == Environment.NORMAL);
|
|
+ catSpawning = getBoolean("gameplay-mechanics.mob-spawning.village-cats", predicate);
|
|
+ patrolSpawning = getBoolean("gameplay-mechanics.mob-spawning.raid-patrols", predicate);
|
|
+ phantomSpawning = getBoolean("gameplay-mechanics.mob-spawning.phantoms", predicate);
|
|
+ villagerTraderSpawning = getBoolean("gameplay-mechanics.mob-spawning.wandering-traders", predicate);
|
|
+ villageSiegeSpawning = getBoolean("gameplay-mechanics.mob-spawning.village-sieges", predicate);
|
|
+ }
|
|
+
|
|
public int elytraDamagePerSecond = 1;
|
|
public double elytraDamageMultiplyBySpeed = 0;
|
|
public boolean elytraIgnoreUnbreaking = false;
|