Advertisement
Guest User

Your code

a guest
Mar 5th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.09 KB | None | 0 0
  1. @EventHandler
  2. public void onBoatCollideWithEntity(VehicleEntityCollisionEvent event) {
  3.    
  4.    // You get the entity that was hit.
  5.    Entity entity = event.getEntity();
  6.  
  7.    // You get the vehicle that hit the entity.
  8.    Vehicle vehicle = event.getVehicle();
  9.  
  10.    // You ignore this event if the vehicle is not a boat.
  11.    if(!(vehicle instanceof Boat)){
  12.       return;
  13.    }
  14.  
  15.    // You get the primary passenger of the vehicle.
  16.    Entity passenger = vehicle.getPassenger();
  17.  
  18.    // You ignore this event if the boat was driven by anything other than a player.
  19.    if(!(entity instanceof Player)){
  20.       return;
  21.    }
  22.  
  23.    // You get the player instance.
  24.    Player player = (Player) passenger;
  25.  
  26.    // You check what entity was hit by the boat.
  27.    switch(entity.getType()){
  28.       case BOAT:
  29.          player.sendMessage("You hit a rival!");
  30.          return;
  31.       case ARMOR_STAND:
  32.          player.sendMessage("You hit an armorstand!");
  33.          player.sendMessage("You have received a boost!");
  34.          // add boost here.
  35.          return;
  36.       default:
  37.          return;    
  38.    }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement