@Override /** * Applies a velocity to each of the entities pushing them away from each other. Args: entity */ public void applyEntityCollision(Entity entity) { org.bukkit.entity.Entity hitEntity = (entity == null) ? null : entity.getBukkitEntity(); VehicleEntityCollisionEvent event = new VehicleEntityCollisionEvent((Vehicle) this.getBukkitEntity(), hitEntity); this.worldObj.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return; } super.applyEntityCollision(entity); }
@EventHandler (ignoreCancelled = true) public void onVehicleEntityCollision(VehicleEntityCollisionEvent event) { Location loc = event.getVehicle().getLocation(BCProtect.location); EntityType type = event.getEntity().getType(); if (! type.equals(EntityType.PLAYER) && ! type.equals(EntityType.MINECART) && ! type.equals(EntityType.MINECART_CHEST) && ! type.equals(EntityType.MINECART_FURNACE) && ! type.equals(EntityType.MINECART_HOPPER) && ! type.equals(EntityType.MINECART_MOB_SPAWNER) && ! type.equals(EntityType.MINECART_TNT) && Util.getQuadtree(loc).contains(loc)) { event.setCancelled(true); event.getEntity().remove(); } }
@Override public void collide(Entity entity) { org.bukkit.entity.Entity hitEntity = (entity == null) ? null : entity.getBukkitEntity(); VehicleEntityCollisionEvent event = new VehicleEntityCollisionEvent((Vehicle) this.getBukkitEntity(), hitEntity); this.world.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return; } super.collide(entity); }
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onVehiclePush(final VehicleEntityCollisionEvent event) { cancelUnlessInteracting(event, event.getEntity()); }
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onVehicleEntityCollision(VehicleEntityCollisionEvent event) { if (this.isObserving(event.getEntity())) { event.setCancelled(true); } }