Fixes and additions to the spawn reason API
Expose an entities spawn reason on the entity. Pre existing entities will return NATURAL if it was a non persistenting Living Entity, SPAWNER for spawners, or DEFAULT since data was not stored. Additionally, add missing spawn reasons. Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com> Co-authored-by: Doc <nachito94@msn.com>
This commit is contained in:
@@ -40,12 +40,10 @@
|
||||
} else {
|
||||
boolean flag = false;
|
||||
RandomSource randomsource = world.getRandom();
|
||||
@@ -123,8 +130,22 @@
|
||||
continue;
|
||||
}
|
||||
@@ -125,6 +132,20 @@
|
||||
} else if (!SpawnPlacements.checkSpawnRules((EntityType) optional.get(), world, EntitySpawnReason.SPAWNER, blockposition1, world.getRandom())) {
|
||||
+ continue;
|
||||
+ }
|
||||
continue;
|
||||
}
|
||||
+ // Paper start - PreCreatureSpawnEvent
|
||||
+ com.destroystokyo.paper.event.entity.PreSpawnerSpawnEvent event = new com.destroystokyo.paper.event.entity.PreSpawnerSpawnEvent(
|
||||
+ io.papermc.paper.util.MCUtil.toLocation(world, d0, d1, d2),
|
||||
@@ -57,13 +55,13 @@
|
||||
+ if (event.shouldAbortSpawn()) {
|
||||
+ break;
|
||||
+ }
|
||||
continue;
|
||||
}
|
||||
+ continue;
|
||||
+ }
|
||||
+ // Paper end - PreCreatureSpawnEvent
|
||||
|
||||
Entity entity = EntityType.loadEntityRecursive(nbttagcompound, world, EntitySpawnReason.SPAWNER, (entity1) -> {
|
||||
entity1.moveTo(d0, d1, d2, entity1.getYRot(), entity1.getXRot());
|
||||
@@ -157,13 +178,26 @@
|
||||
@@ -157,13 +178,27 @@
|
||||
((Mob) entity).finalizeSpawn(world, world.getCurrentDifficultyAt(entity.blockPosition()), EntitySpawnReason.SPAWNER, (SpawnGroupData) null);
|
||||
}
|
||||
|
||||
@@ -82,6 +80,7 @@
|
||||
|
||||
- if (!world.tryAddFreshEntityWithPassengers(entity)) {
|
||||
+ entity.spawnedViaMobSpawner = true; // Paper
|
||||
+ entity.spawnReason = org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER; // Paper - Entity#getEntitySpawnReason
|
||||
+ flag = true; // Paper
|
||||
+ // CraftBukkit start
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callSpawnerSpawnEvent(entity, pos).isCancelled()) {
|
||||
@@ -92,7 +91,7 @@
|
||||
this.delay(world, pos);
|
||||
return;
|
||||
}
|
||||
@@ -174,7 +208,7 @@
|
||||
@@ -174,7 +209,7 @@
|
||||
((Mob) entity).spawnAnim();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user