2019-05-27 09:13:41 +00:00
|
|
|
From c51e1da52848ab61068b678c97edcd3e8f0c5479 Mon Sep 17 00:00:00 2001
|
2019-04-28 17:59:47 +00:00
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
Date: Sun, 14 Jan 2018 17:36:02 -0500
|
|
|
|
Subject: [PATCH] PlayerNaturallySpawnCreaturesEvent
|
|
|
|
|
|
|
|
This event can be used for when you want to exclude a certain player
|
|
|
|
from triggering monster spawns on a server.
|
|
|
|
|
|
|
|
Also a highly more effecient way to blanket block spawns in a world
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
|
2019-05-27 09:13:41 +00:00
|
|
|
index f2b024857..ed9e2e3e1 100644
|
2019-04-28 17:59:47 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
|
2019-05-26 01:56:30 +00:00
|
|
|
@@ -693,12 +693,17 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
|
2019-04-28 17:59:47 +00:00
|
|
|
int chunkRange = world.spigotConfig.mobSpawnRange;
|
|
|
|
chunkRange = (chunkRange > world.spigotConfig.viewDistance) ? (byte) world.spigotConfig.viewDistance : chunkRange;
|
|
|
|
chunkRange = (chunkRange > 8) ? 8 : chunkRange;
|
|
|
|
-
|
|
|
|
- double blockRange = Math.pow(chunkRange << 4, 2);
|
|
|
|
+ final int finalChunkRange = chunkRange; // Paper for lambda below
|
|
|
|
+ //double blockRange = Math.pow(chunkRange << 4, 2); // Paper - use the range from the event
|
|
|
|
// Spigot end
|
|
|
|
|
2019-05-14 02:20:58 +00:00
|
|
|
return this.playerMap.a(chunkcoordintpair.pair()).noneMatch((entityplayer) -> {
|
2019-05-12 22:34:42 +00:00
|
|
|
- return !entityplayer.isSpectator() && a(chunkcoordintpair, (Entity) entityplayer) < blockRange; // Spigot
|
2019-04-28 17:59:47 +00:00
|
|
|
+ // Paper start -
|
2019-05-12 22:34:42 +00:00
|
|
|
+ com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent event
|
2019-04-28 17:59:47 +00:00
|
|
|
+ = new com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent(entityplayer.getBukkitEntity(), (byte)finalChunkRange);
|
|
|
|
+ final double blockRange = (double)((event.getSpawnRadius() << 4) * (event.getSpawnRadius() << 4));
|
2019-05-12 22:34:42 +00:00
|
|
|
+ return event.isCancelled() || (!entityplayer.isSpectator() && a(chunkcoordintpair, (Entity) entityplayer) < blockRange); // Spigot
|
2019-04-28 17:59:47 +00:00
|
|
|
+ // Paper end
|
|
|
|
});
|
|
|
|
}
|
2019-05-12 22:34:42 +00:00
|
|
|
|
2019-04-28 17:59:47 +00:00
|
|
|
--
|
|
|
|
2.21.0
|
|
|
|
|