Vehicle - Questions

Discussion in 'Plugin Development' started by Deathmarine, May 17, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    Deathmarine Retired Staff

    I'm pretty sure from the the look of what I'm trying to it may have been done, but I'm stumped now. Two things. To start I'm trying to make minecarts act as boats on water but on lava or vice versa. However just to make things simple I started with attempt to keep boats working on lava. No Dice. I can keep the boat alive and I can add a passenger but the passenger has a firetick rate that if you change it the boat will no longer function and break on contact with lava.

    This will keep the boat from breaking on lava. But any changes above or below the event cancelled makes the event not cancelled (like event.getVehicle().getPassenger().setFireTicks(0)) and the boat breaks.

    Code:java
    1.  
    2. @EventHandler
    3. public void onVehicleDestroyEvent(VehicleDestroyEvent event){
    4. Vehicle lavaboat = event.getVehicle();
    5. if(lavaboat.getVehicle() instanceof Boat){
    6. if(lavaboat.getLastDamageCause().getCause() == DamageCause.LAVA){
    7. event.setCancelled(true);
    8. }
    9. }
    10. }
    11.  


    I may not be looking at this right considering vehicles are considered entities but are not entities but are vehicle entities? Dunno any incite is helpful.
     
  2. Offline

    TopGear93

  3. Offline

    TheTrixsta

    Since when does a Marine program :p

    Your checking for the destroy event of the vehicle, use the damage event and cancel the damage

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 25, 2016
  4. Offline

    Deathmarine Retired Staff

    See I was thinking that but, I wasn't sure considering that when you place the boat on lava its instantly destroyed, So I was wondering whether it took damage at all.
     
  5. Offline

    LucasEmanuel

    Try it :) The world of development is all about trials and fails ;)
     
  6. Offline

    TheTrixsta

    You might want to register both the damage and the break
     
Thread Status:
Not open for further replies.

Share This Page