From 6f13c9dc55ea15dfea0d9eb95f8dc6ee459f7867 Mon Sep 17 00:00:00 2001 From: Dinnerbone <dinnerbone@dinnerbone.com> Date: Mon, 31 Jan 2011 22:25:27 +0000 Subject: [PATCH] Implemented VEHICLE_COLLISION_BLOCK --- .../java/net/minecraft/server/Entity.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java index cbb65852f4..fb05c52728 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -11,6 +11,10 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import java.util.List; import java.util.Random; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Vehicle; +import org.bukkit.event.vehicle.VehicleBlockCollisionEvent; +import org.bukkit.event.vehicle.VehicleCollisionEvent; public abstract class Entity { @@ -470,6 +474,27 @@ public abstract class Entity { int i1; int j1; + // Craftbukkit start + if ((B) && (getBukkitEntity() instanceof Vehicle)) { + Vehicle vehicle = (Vehicle)getBukkitEntity(); + org.bukkit.World wrld = ((WorldServer)world).getWorld(); + org.bukkit.block.Block block = wrld.getBlockAt(MathHelper.b(locX), MathHelper.b(locY - 0.20000000298023224D - (double) this.height), MathHelper.b(locZ)); + + if (d5 > d0) { + block = block.getFace(BlockFace.SOUTH); + } else if (d5 < d0) { + block = block.getFace(BlockFace.NORTH); + } else if (d7 > d2) { + block = block.getFace(BlockFace.WEST); + } else if (d7 < d2) { + block = block.getFace(BlockFace.EAST); + } + + VehicleBlockCollisionEvent event = new VehicleBlockCollisionEvent(Type.VEHICLE_COLLISION_BLOCK, vehicle, block); + ((WorldServer)world).getServer().getPluginManager().callEvent(event); + } + // Craftbukkit end + if (this.M && !flag) { this.L = (float) ((double) this.L + (double) MathHelper.a(d9 * d9 + d10 * d10) * 0.6D); l = MathHelper.b(this.locX);