mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 23:38:25 +01:00
Add Entity Mount and Dismount Events - very useful for horses! Thanks @lazertester for the idea!
By: md_5 <md_5@live.com.au>
This commit is contained in:
parent
64c5ae2318
commit
115c9744bf
2 changed files with 151 additions and 0 deletions
112
Bukkit-Patches/0010-Entity-Mount-and-Dismount-Events.patch
Normal file
112
Bukkit-Patches/0010-Entity-Mount-and-Dismount-Events.patch
Normal file
|
@ -0,0 +1,112 @@
|
|||
From 0f3bb9c6ff5727243486a28ce8470ec7024d2e70 Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <md_5@live.com.au>
|
||||
Date: Tue, 2 Jul 2013 20:32:53 +1000
|
||||
Subject: [PATCH] Entity Mount and Dismount Events
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/spigotmc/event/entity/EntityDismountEvent.java b/src/main/java/org/spigotmc/event/entity/EntityDismountEvent.java
|
||||
new file mode 100644
|
||||
index 0000000..24d4942
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/spigotmc/event/entity/EntityDismountEvent.java
|
||||
@@ -0,0 +1,39 @@
|
||||
+package org.spigotmc.event.entity;
|
||||
+
|
||||
+import org.bukkit.entity.Entity;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.entity.EntityEvent;
|
||||
+
|
||||
+/**
|
||||
+ * Called when an entity stops riding another entity.
|
||||
+ *
|
||||
+ */
|
||||
+public class EntityDismountEvent extends EntityEvent
|
||||
+{
|
||||
+
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+ private boolean cancelled;
|
||||
+ private final Entity dismounted;
|
||||
+
|
||||
+ public EntityDismountEvent(Entity what, Entity dismounted)
|
||||
+ {
|
||||
+ super( what );
|
||||
+ this.dismounted = dismounted;
|
||||
+ }
|
||||
+
|
||||
+ public Entity getDismounted()
|
||||
+ {
|
||||
+ return dismounted;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public HandlerList getHandlers()
|
||||
+ {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ public static HandlerList getHandlerList()
|
||||
+ {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/spigotmc/event/entity/EntityMountEvent.java b/src/main/java/org/spigotmc/event/entity/EntityMountEvent.java
|
||||
new file mode 100644
|
||||
index 0000000..16aa2a7
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/spigotmc/event/entity/EntityMountEvent.java
|
||||
@@ -0,0 +1,52 @@
|
||||
+package org.spigotmc.event.entity;
|
||||
+
|
||||
+import org.bukkit.entity.Entity;
|
||||
+import org.bukkit.event.Cancellable;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.entity.EntityEvent;
|
||||
+
|
||||
+/**
|
||||
+ * Called when an entity attempts to ride another entity.
|
||||
+ *
|
||||
+ */
|
||||
+public class EntityMountEvent extends EntityEvent implements Cancellable
|
||||
+{
|
||||
+
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+ private boolean cancelled;
|
||||
+ private final Entity mount;
|
||||
+
|
||||
+ public EntityMountEvent(Entity what, Entity mount)
|
||||
+ {
|
||||
+ super( what );
|
||||
+ this.mount = mount;
|
||||
+ }
|
||||
+
|
||||
+ public Entity getMount()
|
||||
+ {
|
||||
+ return mount;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCancelled()
|
||||
+ {
|
||||
+ return cancelled;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setCancelled(boolean cancel)
|
||||
+ {
|
||||
+ this.cancelled = cancel;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public HandlerList getHandlers()
|
||||
+ {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ public static HandlerList getHandlerList()
|
||||
+ {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
||||
--
|
||||
1.8.1.2
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
From 19fdd2e4302b1bc3be272274ee6e77a389d7bb44 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 700e450..ea6762e 100644
|
||||
--- a/src/main/java/net/minecraft/server/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||||
@@ -1413,6 +1413,7 @@ public abstract class Entity {
|
||||
if ((this.bukkitEntity instanceof LivingEntity) && (this.vehicle.getBukkitEntity() instanceof Vehicle)) {
|
||||
VehicleExitEvent event = new VehicleExitEvent((Vehicle) this.vehicle.getBukkitEntity(), (LivingEntity) this.bukkitEntity);
|
||||
pluginManager.callEvent(event);
|
||||
+ pluginManager.callEvent( new org.spigotmc.event.entity.EntityDismountEvent( this.getBukkitEntity(), entity.getBukkitEntity() ) ); // Spigot
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
@@ -1432,6 +1433,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;
|
||||
--
|
||||
1.8.1.2
|
||||
|
Loading…
Reference in a new issue