From 08bd3b86b7734f2c0653d81d71463631b420acc4 Mon Sep 17 00:00:00 2001 From: wizjany Date: Fri, 14 Jun 2019 22:06:36 -0700 Subject: [PATCH] Use the entity registry id instead of translation key when posting PreCreatureSpawnEvent and PreSpawnerSpawnEvent --- .../PreCreatureSpawnEvent.patch | 18 +++--------------- .../PreSpawnerSpawnEvent.patch | 8 ++++++-- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/Spigot-Server-Patches/PreCreatureSpawnEvent.patch b/Spigot-Server-Patches/PreCreatureSpawnEvent.patch index 3cb90aee22..2499495e1b 100644 --- a/Spigot-Server-Patches/PreCreatureSpawnEvent.patch +++ b/Spigot-Server-Patches/PreCreatureSpawnEvent.patch @@ -14,20 +14,8 @@ instead and save a lot of server resources. See: https://github.com/PaperMC/Paper/issues/917 -diff --git a/src/main/java/net/minecraft/server/EntityTypes.java b/src/main/java/net/minecraft/server/EntityTypes.java -index 98eb0d24cc..77d4bbce19 100644 ---- a/src/main/java/net/minecraft/server/EntityTypes.java -+++ b/src/main/java/net/minecraft/server/EntityTypes.java -@@ -0,0 +0,0 @@ public class EntityTypes { - return this.bf; - } - -+ public final MinecraftKey getKey() { return this.g(); } // Paper - OBFHELPER - public MinecraftKey g() { - if (this.bg == null) { - MinecraftKey minecraftkey = IRegistry.ENTITY_TYPE.getKey(this); diff --git a/src/main/java/net/minecraft/server/MobSpawnerAbstract.java b/src/main/java/net/minecraft/server/MobSpawnerAbstract.java -index 93fad14d3f..55764deec4 100644 +index 93fad14d3..55764deec 100644 --- a/src/main/java/net/minecraft/server/MobSpawnerAbstract.java +++ b/src/main/java/net/minecraft/server/MobSpawnerAbstract.java @@ -0,0 +0,0 @@ public abstract class MobSpawnerAbstract { @@ -59,7 +47,7 @@ index 93fad14d3f..55764deec4 100644 Entity entity = EntityTypes.a(nbttagcompound, world, (entity1) -> { entity1.setPositionRotation(d3, d4, d5, entity1.yaw, entity1.pitch); diff --git a/src/main/java/net/minecraft/server/SpawnerCreature.java b/src/main/java/net/minecraft/server/SpawnerCreature.java -index f4f842b863..5da0f2211b 100644 +index f4f842b86..d25c7231d 100644 --- a/src/main/java/net/minecraft/server/SpawnerCreature.java +++ b/src/main/java/net/minecraft/server/SpawnerCreature.java @@ -0,0 +0,0 @@ public final class SpawnerCreature { @@ -78,7 +66,7 @@ index f4f842b863..5da0f2211b 100644 + // Paper start + com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent event; + EntityTypes cls = biomebase_biomemeta.b; -+ org.bukkit.entity.EntityType type = org.bukkit.entity.EntityType.fromName(cls.getKey().getKey()); ++ org.bukkit.entity.EntityType type = org.bukkit.entity.EntityType.fromName(EntityTypes.getName(cls).getKey()); + if (type != null) { + event = new com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent( + MCUtil.toLocation(world, blockposition_mutableblockposition), diff --git a/Spigot-Server-Patches/PreSpawnerSpawnEvent.patch b/Spigot-Server-Patches/PreSpawnerSpawnEvent.patch index 44bd150694..2cd3f77c13 100644 --- a/Spigot-Server-Patches/PreSpawnerSpawnEvent.patch +++ b/Spigot-Server-Patches/PreSpawnerSpawnEvent.patch @@ -9,11 +9,15 @@ SpawnerSpawnEvent gets called instead of the CreatureSpawnEvent for spawners. diff --git a/src/main/java/net/minecraft/server/MobSpawnerAbstract.java b/src/main/java/net/minecraft/server/MobSpawnerAbstract.java -index 55764deec4..dbb8098d6c 100644 +index 55764dee..b2e6e2a7 100644 --- a/src/main/java/net/minecraft/server/MobSpawnerAbstract.java +++ b/src/main/java/net/minecraft/server/MobSpawnerAbstract.java @@ -0,0 +0,0 @@ public abstract class MobSpawnerAbstract { - String key = entityType.getKey().getKey(); + + // Paper start + EntityTypes entityType = optional.get(); +- String key = entityType.getKey().getKey(); ++ String key = EntityTypes.getName(entityType).getKey(); org.bukkit.entity.EntityType type = org.bukkit.entity.EntityType.fromName(key); if (type != null) { - com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent event;