PaperMC/paper-server/nms-patches/net/minecraft/world/level/MobSpawnerAbstract.patch
CraftBukkit/Spigot 5301642c90 Implement SpawnerSpawnEvent
By: md_5 <git@md-5.net>
Also-by: Andy Shulman <andy.shulman@hotmail.com>
2023-06-10 07:22:51 +10:00

24 lines
1.3 KiB
Diff

--- a/net/minecraft/world/level/MobSpawnerAbstract.java
+++ b/net/minecraft/world/level/MobSpawnerAbstract.java
@@ -50,6 +50,7 @@
public void setEntityId(EntityTypes<?> entitytypes, @Nullable World world, RandomSource randomsource, BlockPosition blockposition) {
this.getOrCreateNextSpawnData(world, randomsource, blockposition).getEntityToSpawn().putString("id", BuiltInRegistries.ENTITY_TYPE.getKey(entitytypes).toString());
+ this.spawnPotentials = SimpleWeightedRandomList.empty(); // CraftBukkit - SPIGOT-3496, MC-92282
}
private boolean isNearPlayer(World world, BlockPosition blockposition) {
@@ -152,7 +153,12 @@
}
}
- if (!worldserver.tryAddFreshEntityWithPassengers(entity)) {
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callSpawnerSpawnEvent(entity, blockposition).isCancelled()) {
+ continue;
+ }
+ if (!worldserver.tryAddFreshEntityWithPassengers(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER)) {
+ // CraftBukkit end
this.delay(worldserver, blockposition);
return;
}