Remove broken saddle pig event

This commit is contained in:
md_5 2013-03-23 11:00:20 +11:00
parent d9f3cf3f2c
commit c57fa19eea
2 changed files with 1 additions and 95 deletions

View File

@ -1,4 +1,4 @@
From 475514889958ee40a71012cd24665b094fd7c0a5 Mon Sep 17 00:00:00 2001 From a2a29eb62901c4375eb1809df2fd166e6ac12492 Mon Sep 17 00:00:00 2001
From: James Clarke <jamesrtclarke@me.com> From: James Clarke <jamesrtclarke@me.com>
Date: Sat, 26 Jan 2013 10:39:45 +0000 Date: Sat, 26 Jan 2013 10:39:45 +0000
Subject: [PATCH] ANSI color codes now reset text attributes. Fixes BUKKIT-3508 Subject: [PATCH] ANSI color codes now reset text attributes. Fixes BUKKIT-3508

View File

@ -1,94 +0,0 @@
From f793fd756eb3639cd221fa0c11a6205dc0339cc3 Mon Sep 17 00:00:00 2001
From: TheCryoknight <thecryoknight1@gmail.com>
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