Paper/CraftBukkit-Patches/0040-Entity-Mount-and-Dismount-Events.patch
2014-05-27 17:40:02 +10:00

52 lines
2.5 KiB
Diff

From c0e0deda0bfc821c7e234f387f9b28d079c692a8 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Tue, 2 Jul 2013 20:32:49 +1000
Subject: [PATCH] Entity Mount and Dismount Events
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index e74e6d6..2a192e1 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -1461,6 +1461,7 @@ public abstract class Entity {
}
}
// CraftBukkit end
+ pluginManager.callEvent( new org.spigotmc.event.entity.EntityDismountEvent( this.getBukkitEntity(), this.vehicle.getBukkitEntity() ) ); // Spigot
this.setPositionRotation(this.vehicle.locX, this.vehicle.boundingBox.b + (double) this.vehicle.length, this.vehicle.locZ, this.yaw, this.pitch);
this.vehicle.passenger = null;
@@ -1496,6 +1497,17 @@ public abstract class Entity {
}
}
// CraftBukkit end
+ // Spigot Start
+ if ( entity.world.isChunkLoaded( (int) entity.locX >> 4, (int) entity.locZ >> 4 ) )
+ {
+ org.spigotmc.event.entity.EntityMountEvent event = new org.spigotmc.event.entity.EntityMountEvent( this.getBukkitEntity(), entity.getBukkitEntity() );
+ pluginManager.callEvent( event );
+ if ( event.isCancelled() )
+ {
+ return;
+ }
+ }
+ // Spigot End
if (this.vehicle != null) {
this.vehicle.passenger = null;
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
index 381ba31..1fc7a22 100644
--- a/src/main/java/net/minecraft/server/EntityHuman.java
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
@@ -323,6 +323,7 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen
public void setPassengerOf(Entity entity) {
// CraftBukkit end
if (this.vehicle != null && entity == null) {
+ world.getServer().getPluginManager().callEvent( new org.spigotmc.event.entity.EntityDismountEvent( this.getBukkitEntity(), this.vehicle.getBukkitEntity() ) ); // Spigot
// CraftBukkit start - use parent method instead to correctly fire VehicleExitEvent
Entity originalVehicle = this.vehicle;
// First statement moved down, second statement handled in parent method.
--
1.9.1