From 68b98d4c8fab36d5b139b3a404069d5b99d56886 Mon Sep 17 00:00:00 2001 From: Wesley Wolfe Date: Tue, 20 Mar 2012 02:07:13 -0500 Subject: [PATCH] [Bleeding] Implement ExpBottleEvent; Addresses BUKKIT-888 --- .../net/minecraft/server/EntityThrownExpBottle.java | 11 ++++++++++- .../bukkit/craftbukkit/event/CraftEventFactory.java | 8 ++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/minecraft/server/EntityThrownExpBottle.java b/src/main/java/net/minecraft/server/EntityThrownExpBottle.java index 70b254e930..820b330ec9 100644 --- a/src/main/java/net/minecraft/server/EntityThrownExpBottle.java +++ b/src/main/java/net/minecraft/server/EntityThrownExpBottle.java @@ -28,9 +28,18 @@ public class EntityThrownExpBottle extends EntityProjectile { protected void a(MovingObjectPosition movingobjectposition) { if (!this.world.isStatic) { - this.world.triggerEffect(2002, (int) Math.round(this.locX), (int) Math.round(this.locY), (int) Math.round(this.locZ), 0); + // CraftBukkit moved after event + //this.world.triggerEffect(2002, (int) Math.round(this.locX), (int) Math.round(this.locY), (int) Math.round(this.locZ), 0); int i = 3 + this.world.random.nextInt(5) + this.world.random.nextInt(5); + // CraftBukkit start + org.bukkit.event.entity.ExpBottleEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callExpBottleEvent(this, i); + i = event.getExperience(); + if (event.getShowEffect()) { + this.world.triggerEffect(2002, (int) Math.round(this.locX), (int) Math.round(this.locY), (int) Math.round(this.locZ), 0); + } + // CraftBukkit end + while (i > 0) { int j = EntityExperienceOrb.getOrbValue(i); diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index e7aad88651..cebaa8f034 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -46,6 +46,7 @@ import org.bukkit.entity.Pig; import org.bukkit.entity.PigZombie; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; +import org.bukkit.entity.ThrownExpBottle; import org.bukkit.entity.ThrownPotion; import org.bukkit.event.Event; import org.bukkit.event.block.*; @@ -498,4 +499,11 @@ public class CraftEventFactory { Bukkit.getPluginManager().callEvent(event); return event; } + + public static ExpBottleEvent callExpBottleEvent(Entity entity, int exp) { + ThrownExpBottle bottle = (ThrownExpBottle) entity.getBukkitEntity(); + ExpBottleEvent event = new ExpBottleEvent(bottle, exp); + Bukkit.getPluginManager().callEvent(event); + return event; + } }