geforkt von Mirrors/Paper
00be0b7b30
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: d25437bc Update to Minecraft 1.18-pre8 CraftBukkit Changes: 5a39a236 Update to Minecraft 1.18-pre8 Spigot Changes: 7840c2af Update to Minecraft 1.18-pre8
81 Zeilen
4.6 KiB
Diff
81 Zeilen
4.6 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
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/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
|
index 713be7a4bee692d346a1f94cd891030be53260a5..398f90cacfcf93f6abd395758f0188d785fd764d 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
|
@@ -1105,7 +1105,9 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
|
chunkRange = (chunkRange > level.spigotConfig.viewDistance) ? (byte) level.spigotConfig.viewDistance : chunkRange;
|
|
chunkRange = (chunkRange > 8) ? 8 : chunkRange;
|
|
|
|
- double blockRange = (reducedRange) ? Math.pow(chunkRange << 4, 2) : 16384.0D;
|
|
+ final int finalChunkRange = chunkRange; // Paper for lambda below
|
|
+ //double blockRange = (reducedRange) ? Math.pow(chunkRange << 4, 2) : 16384.0D; // Paper - use from event
|
|
+ double blockRange = 16384.0D; // Paper
|
|
// Spigot end
|
|
long i = chunkcoordintpair.toLong();
|
|
|
|
@@ -1122,6 +1124,15 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
|
}
|
|
|
|
entityplayer = (ServerPlayer) iterator.next();
|
|
+ // Paper start - add PlayerNaturallySpawnCreaturesEvent
|
|
+ com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent event;
|
|
+ blockRange = 16384.0D;
|
|
+ if (reducedRange) {
|
|
+ event = entityplayer.playerNaturallySpawnedEvent;
|
|
+ if (event == null || event.isCancelled()) return false;
|
|
+ blockRange = (double) ((event.getSpawnRadius() << 4) * (event.getSpawnRadius() << 4));
|
|
+ }
|
|
+ // Paper end
|
|
} 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 5be81f72e01cf4f3d5f99b48b8c8a0d7df78f93b..80ccd821d83b318d3758252ce4ed349bfa5acb69 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
|
@@ -827,6 +827,15 @@ public class ServerChunkCache extends ChunkSource {
|
|
boolean flag2 = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !this.level.players().isEmpty(); // CraftBukkit
|
|
|
|
//Collections.shuffle(list); // Paper - no... just no...
|
|
+ // Paper start - call player naturally spawn event
|
|
+ int chunkRange = level.spigotConfig.mobSpawnRange;
|
|
+ chunkRange = (chunkRange > level.spigotConfig.viewDistance) ? (byte) level.spigotConfig.viewDistance : chunkRange;
|
|
+ chunkRange = Math.min(chunkRange, 8);
|
|
+ for (ServerPlayer entityPlayer : this.level.players()) {
|
|
+ entityPlayer.playerNaturallySpawnedEvent = new com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent(entityPlayer.getBukkitEntity(), (byte) chunkRange);
|
|
+ entityPlayer.playerNaturallySpawnedEvent.callEvent();
|
|
+ };
|
|
+ // Paper end
|
|
Iterator iterator1 = list.iterator();
|
|
|
|
while (iterator1.hasNext()) {
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
index ab73818893b00551f8137704a727e33046d43a6a..90bff0dd400a67bcb84f8576bd8326793420919a 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
@@ -1,5 +1,6 @@
|
|
package net.minecraft.server.level;
|
|
|
|
+import com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent;
|
|
import com.google.common.collect.Lists;
|
|
import com.mojang.authlib.GameProfile;
|
|
import com.mojang.datafixers.util.Either;
|
|
@@ -236,6 +237,7 @@ public class ServerPlayer extends Player {
|
|
public boolean sentListPacket = false;
|
|
public Integer clientViewDistance;
|
|
// CraftBukkit end
|
|
+ public PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper
|
|
|
|
public final com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<ServerPlayer> cachedSingleHashSet; // Paper
|
|
|