From 4d4d0ef929efa68bae67fec911717f4cd76183fd Mon Sep 17 00:00:00 2001 From: TheCryoknight Date: Sat, 23 Mar 2013 10:23:23 +1100 Subject: [PATCH] Pull CB PR #1073 by @TheCryoknight - Adds BUKKIT-3821 - Fires vehicle events for saddled pigs --- ...-Fires-vehicle-events-for-saddled-pi.patch | 94 +++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 CraftBukkit-Patches/0042-Adds-BUKKIT-3821-Fires-vehicle-events-for-saddled-pi.patch diff --git a/CraftBukkit-Patches/0042-Adds-BUKKIT-3821-Fires-vehicle-events-for-saddled-pi.patch b/CraftBukkit-Patches/0042-Adds-BUKKIT-3821-Fires-vehicle-events-for-saddled-pi.patch new file mode 100644 index 0000000000..120390aa20 --- /dev/null +++ b/CraftBukkit-Patches/0042-Adds-BUKKIT-3821-Fires-vehicle-events-for-saddled-pi.patch @@ -0,0 +1,94 @@ +From f793fd756eb3639cd221fa0c11a6205dc0339cc3 Mon Sep 17 00:00:00 2001 +From: TheCryoknight +Date: Wed, 20 Mar 2013 12:20:30 -0500 +Subject: [PATCH] Adds BUKKIT-3821 - Fires vehicle events for saddled pigs + +--- + src/main/java/net/minecraft/server/EntityPig.java | 52 ++++++++++++++++++++++- + 1 file changed, 51 insertions(+), 1 deletion(-) + +diff --git a/src/main/java/net/minecraft/server/EntityPig.java b/src/main/java/net/minecraft/server/EntityPig.java +index e9fe7cf..9c9af40 100644 +--- a/src/main/java/net/minecraft/server/EntityPig.java ++++ b/src/main/java/net/minecraft/server/EntityPig.java +@@ -1,6 +1,15 @@ + package net.minecraft.server; + +-import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit ++//CraftBukkit start ++import org.bukkit.Location; ++import org.bukkit.craftbukkit.event.CraftEventFactory; ++import org.bukkit.entity.Vehicle; ++import org.bukkit.event.vehicle.VehicleCreateEvent; ++import org.bukkit.event.vehicle.VehicleDestroyEvent; ++import org.bukkit.event.vehicle.VehicleEnterEvent; ++import org.bukkit.event.vehicle.VehicleMoveEvent; ++import org.bukkit.event.vehicle.VehicleUpdateEvent; ++//CraftBukkit end + + public class EntityPig extends EntityAnimal { + +@@ -78,6 +87,13 @@ public class EntityPig extends EntityAnimal { + if (super.a_(entityhuman)) { + return true; + } else if (this.hasSaddle() && !this.world.isStatic && (this.passenger == null || this.passenger == entityhuman)) { ++ // CraftBukkit start ++ VehicleEnterEvent enterEvent = new VehicleEnterEvent((Vehicle) this.getBukkitEntity(), entityhuman.getBukkitEntity()); ++ this.world.getServer().getPluginManager().callEvent(enterEvent); ++ if (enterEvent.isCancelled()) { ++ return false; ++ } ++ // CraftBukkit end + entityhuman.mount(this); + return true; + } else { +@@ -117,7 +133,17 @@ public class EntityPig extends EntityAnimal { + public void setSaddle(boolean flag) { + if (flag) { + this.datawatcher.watch(16, Byte.valueOf((byte) 1)); ++ this.world.getServer().getPluginManager().callEvent(new VehicleCreateEvent((Vehicle) this.getBukkitEntity())); // CraftBukkit + } else { ++ // CraftBukkit start ++ Vehicle vehicle = (Vehicle) this.getBukkitEntity(); ++ VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, passenger.getBukkitEntity()); ++ this.world.getServer().getPluginManager().callEvent(destroyEvent); ++ ++ if (destroyEvent.isCancelled()) { ++ return; ++ } ++ // CraftBukkit end + this.datawatcher.watch(16, Byte.valueOf((byte) 0)); + } + } +@@ -161,4 +187,28 @@ public class EntityPig extends EntityAnimal { + public EntityAgeable createChild(EntityAgeable entityageable) { + return this.b(entityageable); + } ++ ++ // CraftBukkit start ++ public void l_() { ++ final double prevX = this.locX; ++ final double prevY = this.locY; ++ final double prevZ = this.locZ; ++ final float prevYaw = this.yaw; ++ final float prevPitch = this.pitch; ++ ++ super.l_(); ++ ++ if (this.passenger != null && this.hasSaddle()) { ++ final org.bukkit.World bukkitWorld = this.world.getWorld(); ++ final Location fromLoc = new Location(bukkitWorld, prevX, prevY, prevZ, prevYaw, prevPitch); ++ final Location toLoc = new Location(bukkitWorld, this.locX, this.locY, this.locZ, this.yaw, this.pitch); ++ final Vehicle vehicle = (Vehicle) this.getBukkitEntity(); ++ ++ this.world.getServer().getPluginManager().callEvent(new VehicleUpdateEvent(vehicle)); ++ if (!fromLoc.equals(toLoc)) { ++ this.world.getServer().getPluginManager().callEvent(new VehicleMoveEvent(vehicle, fromLoc, toLoc)); ++ } ++ } ++ } ++ // CraftBukkit end + } +-- +1.8.1-rc2 +