From 228b5e7ccdeef71e16958e014fb99c640f84a7a9 Mon Sep 17 00:00:00 2001 From: Erik Broes Date: Sun, 6 Feb 2011 10:41:53 +0100 Subject: Added VEHICLE_COLLISION_ENTITY which vanished after porting the code --- .../java/net/minecraft/server/EntityMinecart.java | 29 ++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'src/main') diff --git a/src/main/java/net/minecraft/server/EntityMinecart.java b/src/main/java/net/minecraft/server/EntityMinecart.java index 5cbc07b6..c7b980d2 100644 --- a/src/main/java/net/minecraft/server/EntityMinecart.java +++ b/src/main/java/net/minecraft/server/EntityMinecart.java @@ -604,15 +604,40 @@ public class EntityMinecart extends Entity implements IInventory { public void c(Entity entity) { if (!this.world.isStatic) { if (entity != this.passenger) { + + // CraftBukkit start + CraftServer server = ((WorldServer) world).getServer(); + Type eventType = Type.VEHICLE_COLLISION_ENTITY; + Vehicle vehicle = (Vehicle) this.getBukkitEntity(); + org.bukkit.entity.Entity hitEntity = (entity == null) ? null : entity.getBukkitEntity(); + + VehicleEntityCollisionEvent collsionEvent = new VehicleEntityCollisionEvent(eventType, vehicle, hitEntity); + server.getPluginManager().callEvent(collsionEvent); + + if (collsionEvent.isCancelled()) { + return; + } + if (entity instanceof EntityLiving && !(entity instanceof EntityHuman) && this.d == 0 && this.motX * this.motX + this.motZ * this.motZ > 0.01D && this.passenger == null && entity.vehicle == null) { - entity.e((Entity) this); + if (!collsionEvent.isPickupCancelled()) { + eventType = Type.VEHICLE_ENTER; + + VehicleEnterEvent enterEvent = new VehicleEnterEvent(eventType, vehicle, hitEntity); + server.getPluginManager().callEvent(enterEvent); + + if (!enterEvent.isCancelled()) { + entity.e((Entity) this); + } + } } + // CraftBukkit end double d0 = entity.locX - this.locX; double d1 = entity.locZ - this.locZ; double d2 = d0 * d0 + d1 * d1; - if (d2 >= 9.999999747378752E-5D) { + // CraftBukkit - Collision + if (d2 >= 9.9999997473787516E-005D && !collsionEvent.isCollisionCancelled()) { d2 = (double) MathHelper.a(d2); d0 /= d2; d1 /= d2; -- cgit v1.2.3