mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 07:20:24 +01:00
Pull CB PR #1073 by @TheCryoknight - Adds BUKKIT-3821 - Fires vehicle events for saddled pigs
This commit is contained in:
parent
2db4c72233
commit
4d4d0ef929
1 changed files with 94 additions and 0 deletions
|
@ -0,0 +1,94 @@
|
||||||
|
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
|
||||||
|
|
Loading…
Reference in a new issue