2016-03-20 00:29:50 +00:00
|
|
|
From e87ff2924bd5b604551eba4fc075f71a6dbdb95c Mon Sep 17 00:00:00 2001
|
2016-03-03 08:46:15 +00:00
|
|
|
From: md_5 <git@md-5.net>
|
|
|
|
Date: Thu, 3 Mar 2016 19:45:46 +1100
|
|
|
|
Subject: [PATCH] Implement SpawnerSpawnEvent.
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/MobSpawnerAbstract.java b/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
|
|
|
|
index efe792b..a7903a2 100644
|
|
|
|
--- a/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
|
|
|
|
@@ -99,6 +99,9 @@ public abstract class MobSpawnerAbstract {
|
|
|
|
{
|
|
|
|
entity.fromMobSpawner = true;
|
|
|
|
}
|
|
|
|
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callSpawnerSpawnEvent(entity, blockposition).isCancelled()) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
// Spigot End
|
|
|
|
ChunkRegionLoader.a(entity, world, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER); // CraftBukkit
|
|
|
|
world.triggerEffect(2004, blockposition, 0);
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
2016-03-20 00:29:50 +00:00
|
|
|
index bfa218b..dd50e8b 100644
|
2016-03-03 08:46:15 +00:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
2016-03-20 00:29:50 +00:00
|
|
|
@@ -998,6 +998,21 @@ public class CraftEventFactory {
|
2016-03-03 08:46:15 +00:00
|
|
|
return event;
|
|
|
|
}
|
2016-03-12 09:59:15 +00:00
|
|
|
|
2016-03-03 08:46:15 +00:00
|
|
|
+ /**
|
|
|
|
+ * Mob spawner event.
|
|
|
|
+ */
|
|
|
|
+ public static SpawnerSpawnEvent callSpawnerSpawnEvent(Entity spawnee, BlockPosition pos) {
|
|
|
|
+ org.bukkit.craftbukkit.entity.CraftEntity entity = spawnee.getBukkitEntity();
|
|
|
|
+ BlockState state = entity.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()).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;
|
|
|
|
+ }
|
2016-03-12 09:59:15 +00:00
|
|
|
+
|
|
|
|
public static EntityToggleGlideEvent callToggleGlideEvent(EntityLiving entity, boolean gliding) {
|
|
|
|
EntityToggleGlideEvent event = new EntityToggleGlideEvent((LivingEntity) entity.getBukkitEntity(), gliding);
|
|
|
|
entity.world.getServer().getPluginManager().callEvent(event);
|
2016-03-03 08:46:15 +00:00
|
|
|
--
|
|
|
|
2.5.0
|
|
|
|
|