mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-20 09:57:43 +01:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: bca97a8f7 replace spaces in world key (touches #5397) de94f6485 Refactor chat message composition (#5396) e27f334bb [CI-SKIP] Fix makemcdevsrc.sh for nms relocations (#5389) ae15e85da Updated Upstream (CraftBukkit) 26fe0ac5a Only set despawnTimer for Wandering Traders spawned by MobSpawnerTrader (#5391) b748eb7b8 Fix VanillaMobGoalTest#testBukkitMap (#5390) 18dbbb578 [Auto] Updated Upstream (CraftBukkit) fac9cc5d5 [CI-SKIP] Ignore .gitignore 087aa70e7 Deprecate ItemStack#setLore(List<String>) and ItemStack#getLore, add Component based alternatives 9889c651c apply fixup c310f0a61 Updated Upstream (Bukkit/CraftBukkit) f17560ab0 wtf is this t file -jmp 347f3a9b8 fix compile 700e9e6a5 rebase cf4dc464a Revert de5f4e469...c270abe96 6870db613 script & POM fix 743c6533c Replace ** with * (BSD/macOS) 376d7b097 Don't remove the .java fcb3fd42a Fix macOS/BSD support 8cfc05249 Link correctly ba1031ca7 Rename work dir c8d844ab7 Actually fix preloading this time e62aa5e3e Fix class preloading 1c03cf898 It's mojang math, not minecraft math 1034873df Apply fixups 39b125771 Use revision file 956150da7 Welcome to 1.16.5-R0.2 ccb217c01 Change cache keys 0d217001c more work f6d820f07 It compiles 0f78e9525 More work 1718f61bf Updated Upstream (CraftBukkit/Spigot) b28d46114 Update scripts for NMS repackaging Tuinity Changes: 9bdcb9b8e Delete work dir when running jar 6351d7ca7 Update Upstream (Paper) 932c199a6 Generate md-dev correctly bf3e73778 Make packet limiter work from IDE 1686f3861 Fix packet limiter config f40f7b425 Update README.md styling (#264) da1c3ace5 GH Actions Changes (#213) 5f325ecf1 Update Upstream (Paper) 0f83fe48d Update Upstream (Paper) Airplane Changes: f94d39947 Merge pull request #18 from notOM3GA/upstream/nms-repackage 0fc622631 Force build for Flare update 08439d6a9 Update Upstream (Tuinity)
177 lines
10 KiB
Diff
177 lines
10 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/level/WorldServer.java b/src/main/java/net/minecraft/server/level/WorldServer.java
|
|
index dd1a0cffedc434d570c1b03fa8cf55d90de1f324..c74e82feb007764d77f8f9b7f910f7b113e3bf40 100644
|
|
--- a/src/main/java/net/minecraft/server/level/WorldServer.java
|
|
+++ b/src/main/java/net/minecraft/server/level/WorldServer.java
|
|
@@ -92,6 +92,7 @@ import net.minecraft.world.entity.EnumCreatureType;
|
|
import net.minecraft.world.entity.ReputationHandler;
|
|
import net.minecraft.world.entity.ai.navigation.NavigationAbstract;
|
|
import net.minecraft.world.entity.ai.village.ReputationEvent;
|
|
+import net.minecraft.world.entity.ai.village.VillageSiege;
|
|
import net.minecraft.world.entity.ai.village.poi.VillagePlace;
|
|
import net.minecraft.world.entity.ai.village.poi.VillagePlaceType;
|
|
import net.minecraft.world.entity.animal.EntityAnimal;
|
|
@@ -101,6 +102,8 @@ import net.minecraft.world.entity.animal.horse.EntityHorseSkeleton;
|
|
import net.minecraft.world.entity.boss.EntityComplexPart;
|
|
import net.minecraft.world.entity.boss.enderdragon.EntityEnderDragon;
|
|
import net.minecraft.world.entity.item.EntityItem;
|
|
+import net.minecraft.world.entity.npc.MobSpawnerCat;
|
|
+import net.minecraft.world.entity.npc.MobSpawnerTrader;
|
|
import net.minecraft.world.entity.npc.NPC;
|
|
import net.minecraft.world.entity.player.EntityHuman;
|
|
import net.minecraft.world.entity.raid.PersistentRaid;
|
|
@@ -133,6 +136,8 @@ import net.minecraft.world.level.chunk.storage.RegionFile;
|
|
import net.minecraft.world.level.dimension.DimensionManager;
|
|
import net.minecraft.world.level.dimension.end.EnderDragonBattle;
|
|
import net.minecraft.world.level.levelgen.HeightMap;
|
|
+import net.minecraft.world.level.levelgen.MobSpawnerPatrol;
|
|
+import net.minecraft.world.level.levelgen.MobSpawnerPhantom;
|
|
import net.minecraft.world.level.levelgen.feature.StructureGenerator;
|
|
import net.minecraft.world.level.levelgen.structure.StructureBoundingBox;
|
|
import net.minecraft.world.level.levelgen.structure.StructureStart;
|
|
@@ -550,7 +555,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/minecraft/world/entity/npc/MobSpawnerTrader.java b/src/main/java/net/minecraft/world/entity/npc/MobSpawnerTrader.java
|
|
index 7c8a2151be8a0f48cba1c15d231d5dbdb500b4d6..361771fc4fcf16b1b013c550734019535cef2924 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/npc/MobSpawnerTrader.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/npc/MobSpawnerTrader.java
|
|
@@ -5,6 +5,7 @@ import java.util.Optional;
|
|
import java.util.Random;
|
|
import javax.annotation.Nullable;
|
|
import net.minecraft.core.BlockPosition;
|
|
+import net.minecraft.core.EnumDirection;
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
import net.minecraft.network.chat.IChatBaseComponent;
|
|
import net.minecraft.server.level.EntityPlayer;
|
|
@@ -153,7 +154,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/world/level/World.java b/src/main/java/net/minecraft/world/level/World.java
|
|
index c75b1b1e8d99157336065f561d40ac803239c6b7..06ecb1ec2b92f0978c57de6353f63a02e6e363da 100644
|
|
--- a/src/main/java/net/minecraft/world/level/World.java
|
|
+++ b/src/main/java/net/minecraft/world/level/World.java
|
|
@@ -250,7 +250,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
|
|
this.paperConfig = new com.destroystokyo.paper.PaperWorldConfig(((net.minecraft.world.level.storage.WorldDataServer) worlddatamutable).getName(), this.spigotConfig); // Paper
|
|
this.chunkPacketBlockController = this.paperConfig.antiXray ? new ChunkPacketBlockControllerAntiXray(this, executor) : ChunkPacketBlockController.NO_OPERATION_INSTANCE; // Paper - Anti-Xray
|
|
this.tuinityConfig = new com.tuinity.tuinity.config.TuinityConfig.WorldConfig(((net.minecraft.world.level.storage.WorldDataServer)worlddatamutable).getName()); // Tuinity - Server Config
|
|
- this.purpurConfig = new net.pl3x.purpur.PurpurWorldConfig((((net.minecraft.world.level.storage.WorldDataServer)worlddatamutable).getName())); // Purpur
|
|
+ this.purpurConfig = new net.pl3x.purpur.PurpurWorldConfig((((net.minecraft.world.level.storage.WorldDataServer)worlddatamutable).getName()), env); // Purpur
|
|
this.generator = gen;
|
|
this.world = new CraftWorld((WorldServer) this, gen, env);
|
|
this.ticksPerAnimalSpawns = this.getServer().getTicksPerAnimalSpawns(); // CraftBukkit
|
|
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
index 3e1b97a4003cea3af511ed9b7f13f8a5373f9a20..1d144ed296120eccee1001fd1299ead48351cbfa 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.world.level.block.Blocks;
|
|
import net.minecraft.world.item.Item;
|
|
import net.minecraft.world.item.Items;
|
|
import net.minecraft.resources.MinecraftKey;
|
|
+import org.apache.commons.lang3.BooleanUtils;
|
|
+import org.bukkit.World;
|
|
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 World.Environment environment;
|
|
|
|
- public PurpurWorldConfig(String worldName) {
|
|
+ public PurpurWorldConfig(String worldName, World.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 == World.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;
|