Check for missing EntityType for PreCreatureSpawnEvent - Resolves #973
This commit is contained in:
parent
d5023110eb
commit
2f0e48c89a
|
@ -1,4 +1,4 @@
|
||||||
From b27bbefc11af081a7e8e7e5212b964c8fc814777 Mon Sep 17 00:00:00 2001
|
From db5414cc10e2023fb1c49a256c053773e672b478 Mon Sep 17 00:00:00 2001
|
||||||
From: Aikar <aikar@aikar.co>
|
From: Aikar <aikar@aikar.co>
|
||||||
Date: Sun, 14 Jan 2018 17:01:31 -0500
|
Date: Sun, 14 Jan 2018 17:01:31 -0500
|
||||||
Subject: [PATCH] PreCreatureSpawnEvent
|
Subject: [PATCH] PreCreatureSpawnEvent
|
||||||
|
@ -15,7 +15,7 @@ instead and save a lot of server resources.
|
||||||
See: https://github.com/PaperMC/Paper/issues/917
|
See: https://github.com/PaperMC/Paper/issues/917
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/MobSpawnerAbstract.java b/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
|
diff --git a/src/main/java/net/minecraft/server/MobSpawnerAbstract.java b/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
|
||||||
index c29df55fa..d6c73a5a0 100644
|
index c29df55fa..3c591e67e 100644
|
||||||
--- a/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
|
--- a/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
|
||||||
+++ b/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
|
+++ b/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
|
||||||
@@ -1,6 +1,7 @@
|
@@ -1,6 +1,7 @@
|
||||||
|
@ -26,7 +26,7 @@ index c29df55fa..d6c73a5a0 100644
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@@ -87,6 +88,23 @@ public abstract class MobSpawnerAbstract {
|
@@ -87,6 +88,29 @@ public abstract class MobSpawnerAbstract {
|
||||||
double d3 = j >= 1 ? nbttaglist.f(0) : (double) blockposition.getX() + (world.random.nextDouble() - world.random.nextDouble()) * (double) this.spawnRange + 0.5D;
|
double d3 = j >= 1 ? nbttaglist.f(0) : (double) blockposition.getX() + (world.random.nextDouble() - world.random.nextDouble()) * (double) this.spawnRange + 0.5D;
|
||||||
double d4 = j >= 2 ? nbttaglist.f(1) : (double) (blockposition.getY() + world.random.nextInt(3) - 1);
|
double d4 = j >= 2 ? nbttaglist.f(1) : (double) (blockposition.getY() + world.random.nextInt(3) - 1);
|
||||||
double d5 = j >= 3 ? nbttaglist.f(2) : (double) blockposition.getZ() + (world.random.nextDouble() - world.random.nextDouble()) * (double) this.spawnRange + 0.5D;
|
double d5 = j >= 3 ? nbttaglist.f(2) : (double) blockposition.getZ() + (world.random.nextDouble() - world.random.nextDouble()) * (double) this.spawnRange + 0.5D;
|
||||||
|
@ -34,44 +34,55 @@ index c29df55fa..d6c73a5a0 100644
|
||||||
+ if (this.getMobName() == null) {
|
+ if (this.getMobName() == null) {
|
||||||
+ return;
|
+ return;
|
||||||
+ }
|
+ }
|
||||||
+ com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent event;
|
+ String key = this.getMobName().getKey();
|
||||||
+ event = new com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent(
|
+ org.bukkit.entity.EntityType type = org.bukkit.entity.EntityType.fromName(key);
|
||||||
+ MCUtil.toLocation(world, d3, d4, d5),
|
+ if (type != null) {
|
||||||
+ org.bukkit.entity.EntityType.fromName(this.getMobName().getKey()),
|
+ com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent event;
|
||||||
+ org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER
|
+ event = new com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent(
|
||||||
+ );
|
+ MCUtil.toLocation(world, d3, d4, d5),
|
||||||
+ if (!event.callEvent()) {
|
+ type,
|
||||||
+ if (event.shouldAbortSpawn()) {
|
+ org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER
|
||||||
+ break;
|
+ );
|
||||||
|
+ if (!event.callEvent()) {
|
||||||
|
+ if (event.shouldAbortSpawn()) {
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ continue;
|
||||||
+ }
|
+ }
|
||||||
+ continue;
|
+ } else {
|
||||||
|
+ MinecraftServer.LOGGER.warn("Warning, could not find EntityType for " + key + " - Please report this to Paper at https://github.com/PaperMC/Paper/issues");
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
Entity entity = ChunkRegionLoader.a(nbttagcompound, world, d3, d4, d5, false);
|
Entity entity = ChunkRegionLoader.a(nbttagcompound, world, d3, d4, d5, false);
|
||||||
|
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
diff --git a/src/main/java/net/minecraft/server/SpawnerCreature.java b/src/main/java/net/minecraft/server/SpawnerCreature.java
|
diff --git a/src/main/java/net/minecraft/server/SpawnerCreature.java b/src/main/java/net/minecraft/server/SpawnerCreature.java
|
||||||
index 2cd063829..1137dda86 100644
|
index 2cd063829..f64de94fa 100644
|
||||||
--- a/src/main/java/net/minecraft/server/SpawnerCreature.java
|
--- a/src/main/java/net/minecraft/server/SpawnerCreature.java
|
||||||
+++ b/src/main/java/net/minecraft/server/SpawnerCreature.java
|
+++ b/src/main/java/net/minecraft/server/SpawnerCreature.java
|
||||||
@@ -184,6 +184,22 @@ public final class SpawnerCreature {
|
@@ -184,6 +184,27 @@ public final class SpawnerCreature {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (worldserver.a(enumcreaturetype, biomebase_biomemeta, (BlockPosition) blockposition_mutableblockposition) && a(EntityPositionTypes.a(biomebase_biomemeta.b), worldserver, blockposition_mutableblockposition)) {
|
if (worldserver.a(enumcreaturetype, biomebase_biomemeta, (BlockPosition) blockposition_mutableblockposition) && a(EntityPositionTypes.a(biomebase_biomemeta.b), worldserver, blockposition_mutableblockposition)) {
|
||||||
+ // Paper start
|
+ // Paper start
|
||||||
+ com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent event;
|
+ com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent event;
|
||||||
+ event = new com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent(
|
+ Class<? extends EntityInsentient> cls = biomebase_biomemeta.b;
|
||||||
+ MCUtil.toLocation(worldserver, blockposition_mutableblockposition),
|
+ org.bukkit.entity.EntityType type = EntityTypes.clsToTypeMap.get(cls);
|
||||||
+ EntityTypes.clsToTypeMap.get(biomebase_biomemeta.b),
|
+ if (type != null) {
|
||||||
+ SpawnReason.NATURAL
|
+ event = new com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent(
|
||||||
+ );
|
+ MCUtil.toLocation(worldserver, blockposition_mutableblockposition),
|
||||||
+ if (!event.callEvent()) {
|
+ type, SpawnReason.NATURAL
|
||||||
+ if (event.shouldAbortSpawn()) {
|
+ );
|
||||||
+ continue label120;
|
+ if (!event.callEvent()) {
|
||||||
|
+ if (event.shouldAbortSpawn()) {
|
||||||
|
+ continue label120;
|
||||||
|
+ }
|
||||||
|
+ j1 += l2;
|
||||||
|
+ ++j4;
|
||||||
|
+ continue;
|
||||||
+ }
|
+ }
|
||||||
+ j1 += l2;
|
+ } else {
|
||||||
+ ++j4;
|
+ MinecraftServer.LOGGER.warn("Warning, could not find EntityType for " + cls.getName() + " contains: " + (EntityTypes.clsToTypeMap.containsKey(cls) ? "yes" : "no") + " - Please report this to Paper at https://github.com/PaperMC/Paper/issues");
|
||||||
+ continue;
|
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
EntityInsentient entityinsentient;
|
EntityInsentient entityinsentient;
|
||||||
|
|
Loading…
Reference in New Issue