mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-20 18:07:43 +01:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: 8c74d3126 Updated Upstream (Bukkit) (#5359) fd3c66a91 bug #5362 - correctly pass "render type" when registering a new scoreboard objective 39c487b37 Add per-command perms for paper command cdbf2578c Add Item Rarity API (#5352) d80e43647 [CI-SKIP] Removal from the MIT list (#5345) Tuinity Changes: aea6b8347 Merge dev/playerchunkloading 722c7ca8a Use hash table for maintaing changed block set 98ae59d85 Custom table implementation for blockstate state lookups 8b8704fb6 Oprimise map impl for tracked players ea71d6ba4 Optimise snow & ice in chunk ticking 9871d4ce5 Remove chunk lookup & lambda allocation from counting mobs 5a4a35f3e Add patreon 7d93d9618 Refactor data management for region manager c3035219f Change license from MIT to LGPLv3 Airplane Changes: 580f380b6 Updated Upstream (Tuinity) 82253fd36 Early return optimization for target finding 9572643bb Cache entityhuman display name 5df98254f Remove iterators from inventory contains 18d2be193 Merge pull request #14 from violetwtf/patch-1 f716d4c33 Merge pull request #13 from violetwtf/master 128cbe519 Reduce entity chunk ticking checks from 3 to 1 03ac0933b Skip copying unloading tile entities 97dd027b5 Smaller pool size for tracking 9e9f57be4 Only set up Flare if token is available
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 341af7474690b929cfa3e35cd464bbbbacb6685e..ad00ff2bd525768e4f06631d16b912c61c8eee28 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 bb7cf83027ad0d0679fb208147f3481dbe280a82..42e06121f20b5366627b9612994187066c73328f 100644
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
|
@@ -187,7 +187,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 b7a17eafe7355b9c9247a9c79495134b43971aaf..5508211d5922ef8072d929a5eb38c4d34f04c686 100644
|
|
--- a/src/main/java/net/minecraft/server/WorldServer.java
|
|
+++ b/src/main/java/net/minecraft/server/WorldServer.java
|
|
@@ -436,7 +436,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 94a870113dc45201379c1efc7e83162c303573df..c8666ce6bdf2e61dd3ccc7ff6cc0810559ce3f5b 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));
|
|
@@ -173,6 +184,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;
|