mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-06 08:17:44 +01:00
Implement SpawnerSpawnEvent
By: md_5 <git@md-5.net> Also-by: Andy Shulman <andy.shulman@hotmail.com>
This commit is contained in:
parent
82dccdf1a6
commit
5301642c90
@ -8,12 +8,17 @@
|
||||
}
|
||||
|
||||
private boolean isNearPlayer(World world, BlockPosition blockposition) {
|
||||
@@ -152,7 +153,7 @@
|
||||
@@ -152,7 +153,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
- if (!worldserver.tryAddFreshEntityWithPassengers(entity)) {
|
||||
+ if (!worldserver.tryAddFreshEntityWithPassengers(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER)) { // CraftBukkit
|
||||
+ // 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;
|
||||
}
|
||||
|
@ -195,6 +195,7 @@ import org.bukkit.event.entity.PlayerLeashEntityEvent;
|
||||
import org.bukkit.event.entity.PotionSplashEvent;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
||||
import org.bukkit.event.entity.SpawnerSpawnEvent;
|
||||
import org.bukkit.event.entity.StriderTemperatureChangeEvent;
|
||||
import org.bukkit.event.entity.VillagerCareerChangeEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
@ -1519,6 +1520,21 @@ public class CraftEventFactory {
|
||||
return event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mob spawner event.
|
||||
*/
|
||||
public static SpawnerSpawnEvent callSpawnerSpawnEvent(Entity spawnee, BlockPosition pos) {
|
||||
org.bukkit.craftbukkit.entity.CraftEntity entity = spawnee.getBukkitEntity();
|
||||
BlockState state = CraftBlock.at(spawnee.level(), pos).getState();
|
||||
if (!(state instanceof org.bukkit.block.CreatureSpawner)) {
|
||||
state = null;
|
||||
}
|
||||
|
||||
SpawnerSpawnEvent event = new SpawnerSpawnEvent(entity, (org.bukkit.block.CreatureSpawner) state);
|
||||
entity.getServer().getPluginManager().callEvent(event);
|
||||
return event;
|
||||
}
|
||||
|
||||
public static EntityToggleGlideEvent callToggleGlideEvent(EntityLiving entity, boolean gliding) {
|
||||
EntityToggleGlideEvent event = new EntityToggleGlideEvent((LivingEntity) entity.getBukkitEntity(), gliding);
|
||||
entity.level().getCraftServer().getPluginManager().callEvent(event);
|
||||
|
Loading…
Reference in New Issue
Block a user