Fix PlayerNaturallySpawnCreaturesEvent

Trivia: Did you know that events need to be called to work?
This commit is contained in:
Shane Freeder 2019-06-11 02:45:46 +01:00
parent 1c68c72b1f
commit 16909a3637
No known key found for this signature in database
GPG Key ID: A3F61EA5A085289C
2 changed files with 9 additions and 8 deletions

View File

@ -1,4 +1,4 @@
From e049f5b213b198902b0407e9e9c15cd5c2569034 Mon Sep 17 00:00:00 2001 From 20180a0a3e12ef3b149a633e6d0018f83f0002bb Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co> From: Aikar <aikar@aikar.co>
Date: Sun, 14 Jan 2018 17:36:02 -0500 Date: Sun, 14 Jan 2018 17:36:02 -0500
Subject: [PATCH] PlayerNaturallySpawnCreaturesEvent Subject: [PATCH] PlayerNaturallySpawnCreaturesEvent
@ -9,10 +9,10 @@ from triggering monster spawns on a server.
Also a highly more effecient way to blanket block spawns in a world 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 diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
index fba9f4b8a1..f5e62b0418 100644 index fba9f4b8a1..6c0a1eb413 100644
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java --- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java +++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
@@ -764,11 +764,22 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { @@ -764,11 +764,23 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
chunkRange = (chunkRange > world.spigotConfig.viewDistance) ? (byte) world.spigotConfig.viewDistance : chunkRange; chunkRange = (chunkRange > world.spigotConfig.viewDistance) ? (byte) world.spigotConfig.viewDistance : chunkRange;
chunkRange = (chunkRange > 8) ? 8 : chunkRange; chunkRange = (chunkRange > 8) ? 8 : chunkRange;
@ -28,6 +28,7 @@ index fba9f4b8a1..f5e62b0418 100644
+ double blockRange = 16384.0D; + double blockRange = 16384.0D;
+ if (reducedRange) { + if (reducedRange) {
+ event = new com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent(entityplayer.getBukkitEntity(), (byte) finalChunkRange); + event = new com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent(entityplayer.getBukkitEntity(), (byte) finalChunkRange);
+ event.callEvent();
+ blockRange = (double) ((event.getSpawnRadius() << 4) * (event.getSpawnRadius() << 4)); + blockRange = (double) ((event.getSpawnRadius() << 4) * (event.getSpawnRadius() << 4));
+ if (event.isCancelled()) return true; + if (event.isCancelled()) return true;
+ } + }

View File

@ -1,4 +1,4 @@
From b06c48f69f98f42c9daa47871ab113c74a771f88 Mon Sep 17 00:00:00 2001 From 0e27f02a7fe0bb667452bc916eb80ef1ac2f1b86 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co> From: Aikar <aikar@aikar.co>
Date: Sat, 21 Jul 2018 08:25:40 -0400 Date: Sat, 21 Jul 2018 08:25:40 -0400
Subject: [PATCH] Add Debug Entities option to debug dupe uuid issues Subject: [PATCH] Add Debug Entities option to debug dupe uuid issues
@ -19,10 +19,10 @@ index ddfa88bac5..291a8029ed 100644
if (bukkitEntity == null) { if (bukkitEntity == null) {
bukkitEntity = CraftEntity.getEntity(world.getServer(), this); bukkitEntity = CraftEntity.getEntity(world.getServer(), this);
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
index f5e62b0418..7bdf0e2d67 100644 index 6c0a1eb413..8fcd721eeb 100644
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java --- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java +++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
@@ -931,6 +931,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { @@ -932,6 +932,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
} else { } else {
PlayerChunkMap.EntityTracker playerchunkmap_entitytracker = new PlayerChunkMap.EntityTracker(entity, i, j, entitytypes.isDeltaTracking()); PlayerChunkMap.EntityTracker playerchunkmap_entitytracker = new PlayerChunkMap.EntityTracker(entity, i, j, entitytypes.isDeltaTracking());
@ -30,7 +30,7 @@ index f5e62b0418..7bdf0e2d67 100644
this.trackedEntities.put(entity.getId(), playerchunkmap_entitytracker); this.trackedEntities.put(entity.getId(), playerchunkmap_entitytracker);
playerchunkmap_entitytracker.track(this.world.getPlayers()); playerchunkmap_entitytracker.track(this.world.getPlayers());
if (entity instanceof EntityPlayer) { if (entity instanceof EntityPlayer) {
@@ -973,7 +974,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { @@ -974,7 +975,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
if (playerchunkmap_entitytracker1 != null) { if (playerchunkmap_entitytracker1 != null) {
playerchunkmap_entitytracker1.a(); playerchunkmap_entitytracker1.a();
} }
@ -40,7 +40,7 @@ index f5e62b0418..7bdf0e2d67 100644
protected void g() { protected void g() {
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index d7229f100b..5cf3aea4fc 100644 index 0fc24f2076..299a316a4b 100644
--- a/src/main/java/net/minecraft/server/World.java --- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java
@@ -68,6 +68,7 @@ public abstract class World implements IIBlockAccess, GeneratorAccess, AutoClose @@ -68,6 +68,7 @@ public abstract class World implements IIBlockAccess, GeneratorAccess, AutoClose