diff options
author | Nassim Jahnke <[email protected]> | 2024-12-03 17:58:41 +0100 |
---|---|---|
committer | Nassim Jahnke <[email protected]> | 2024-12-03 17:58:41 +0100 |
commit | c0a3d51ab35930e410fcd9752ceaff6c3f581c24 (patch) | |
tree | f53076a8b0787d2f544f73f468df94619e5eb1a5 /patches/server/0163-PlayerNaturallySpawnCreaturesEvent.patch | |
parent | da7138233f6392e791d790d1c3407414c855f9c2 (diff) | |
download | Paper-c0a3d51ab35930e410fcd9752ceaff6c3f581c24.tar.gz Paper-c0a3d51ab35930e410fcd9752ceaff6c3f581c24.zip |
Start update, apply API patches
Diffstat (limited to 'patches/server/0163-PlayerNaturallySpawnCreaturesEvent.patch')
-rw-r--r-- | patches/server/0163-PlayerNaturallySpawnCreaturesEvent.patch | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/patches/server/0163-PlayerNaturallySpawnCreaturesEvent.patch b/patches/server/0163-PlayerNaturallySpawnCreaturesEvent.patch deleted file mode 100644 index b510c92555..0000000000 --- a/patches/server/0163-PlayerNaturallySpawnCreaturesEvent.patch +++ /dev/null @@ -1,74 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Aikar <[email protected]> -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/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index 261943f1f188643793a72bd239dfc5fe604e3b99..e211cd62b9381df353c0921bfaa6ad63f251a6ac 100644 ---- a/src/main/java/net/minecraft/server/level/ChunkMap.java -+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java -@@ -1094,11 +1094,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider - } - - private boolean anyPlayerCloseEnoughForSpawningInternal(ChunkPos chunkcoordintpair, boolean reducedRange) { -- int chunkRange = this.level.spigotConfig.mobSpawnRange; -- chunkRange = (chunkRange > this.level.spigotConfig.viewDistance) ? (byte) this.level.spigotConfig.viewDistance : chunkRange; -- chunkRange = (chunkRange > 8) ? 8 : chunkRange; -- -- double blockRange = (reducedRange) ? Math.pow(chunkRange << 4, 2) : 16384.0D; -+ double blockRange; // Paper - use from event - // Spigot end - Iterator iterator = this.playerMap.getAllPlayers().iterator(); - -@@ -1110,6 +1106,15 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider - } - - entityplayer = (ServerPlayer) iterator.next(); -+ // Paper start - PlayerNaturallySpawnCreaturesEvent -+ com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent event; -+ blockRange = 16384.0D; -+ if (reducedRange) { -+ event = entityplayer.playerNaturallySpawnedEvent; -+ if (event == null || event.isCancelled()) continue; -+ blockRange = (double) ((event.getSpawnRadius() << 4) * (event.getSpawnRadius() << 4)); -+ } -+ // Paper end - PlayerNaturallySpawnCreaturesEvent - } while (!this.playerIsCloseEnoughForSpawning(entityplayer, chunkcoordintpair, blockRange)); // Spigot - - return true; -diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index 2e2976efcf99de269f67dec2c87cb910ff280562..f4fa64ab18573cb9a22a9bfb79a351c388d1aaa5 100644 ---- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java -+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -@@ -501,6 +501,14 @@ public class ServerChunkCache extends ChunkSource { - List list1; - - if (flag && (this.spawnEnemies || this.spawnFriendlies)) { -+ // Paper start - PlayerNaturallySpawnCreaturesEvent -+ for (ServerPlayer entityPlayer : this.level.players()) { -+ int chunkRange = Math.min(level.spigotConfig.mobSpawnRange, entityPlayer.getBukkitEntity().getViewDistance()); -+ chunkRange = Math.min(chunkRange, 8); -+ entityPlayer.playerNaturallySpawnedEvent = new com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent(entityPlayer.getBukkitEntity(), (byte) chunkRange); -+ entityPlayer.playerNaturallySpawnedEvent.callEvent(); -+ } -+ // Paper end - PlayerNaturallySpawnCreaturesEvent - boolean flag1 = this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) != 0L && this.level.getLevelData().getGameTime() % this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) == 0L; // CraftBukkit - - list1 = NaturalSpawner.getFilteredSpawningCategories(spawnercreature_d, this.spawnFriendlies, this.spawnEnemies, flag1, this.level); // CraftBukkit -diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java -index 0432304139fada99dff884ebf8d08dbf9afc45c7..8fd3802d8e293e35478666bd4e921d58e1ce5b41 100644 ---- a/src/main/java/net/minecraft/server/level/ServerPlayer.java -+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java -@@ -314,6 +314,7 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player { - public String kickLeaveMessage = null; // SPIGOT-3034: Forward leave message to PlayerQuitEvent - // CraftBukkit end - public boolean isRealPlayer; // Paper -+ public com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper - PlayerNaturallySpawnCreaturesEvent - - public ServerPlayer(MinecraftServer server, ServerLevel world, GameProfile profile, ClientInformation clientOptions) { - super(world, world.getSharedSpawnPos(), world.getSharedSpawnAngle(), profile); |