Exit Custom Entity

Discussion in 'Plugin Development' started by ColaCraft, Jan 24, 2014.

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

    ColaCraft

    I have set up a custom entity/mount using the tutorials found in the Resources section. The entity I am using is a spider. It works perfectly, and I can ride the spider like it is a horse (of sorts)

    Here is my issue:

    Code:java
    1. @EventHandler
    2.  
    3. public void onVehicleExit(VehicleExitEvent event){
    4.  
    5. Vehicle v = event.getExited();
    6.  
    7. if(v istanceof EntityType.SPIDER){
    8.  
    9. CustomEntitySpider s = (CustomEntitySpider) v;
    10.  
    11. s.remove();
    12.  
    13. console.out.println("It works");
    14.  
    15. }else{
    16.  
    17. event.setCancelled(true);
    18.  
    19. }
    20.  
    21. }


    Pretty much, it doesn't trigger any thing when I exit the spider- it doesn't treat it as a vehicle. Is there a quick fix without implementing Vehicle on the CusomEntitySpider class??


    This is not the actual code I use in my plugin, just an example I quickly wrote while in school. The issue is the spider triggering the VehicleExitEvent
     
  2. Offline

    TryB4

    ColaCraft
    I think VehicleExitEvent is currently broken, However I am not sure.
     
  3. Offline

    ColaCraft


    I use this for horses, and it works perfectly. It removes the horse and sends the player "You have left your mount!"

    I even added an else{} to check if it was a vehicle at all and it worked on pigs (regular not custom).

    I can only conclude that it has either something to do with the CustomEntity or the fact that the other things I have tried wear a saddle
     
  4. Offline

    TryB4

    ColaCraft
    try making a bukkitrunnable which checks if the spider has a vehicle - if not remove it
     
  5. Offline

    fireblast709

    Vehicle v is never an instance of an EntityType, since EntityType is an enum
     
  6. Offline

    ColaCraft


    So do I need to implement Vehicle into my CustomEntity or just set the vehicle to EntityType?
     
  7. Offline

    fireblast709

    ColaCraft they are not comparable. Besides, if it doesn't implement Vehicle how can it fire a VehicleEvent ;)?
     
  8. Offline

    ColaCraft

    --Bump--

    I implemented Vehicle into my custom entity class, no avail.

    Yes, I filled out every constructor for Vehicle.

    Thanks for helping!
     
  9. Offline

    xTrollxDudex

  10. Offline

    ColaCraft


    I posted on the original tutorial thread, and he said I need to extend it CraftCreature- can you maybe elaborate? The way he does it is he has 3 classes per creature he rides & maybe 10 other classes to extend them.
     
  11. Offline

    Garris0n

    First of all, you need to check if v.getType().equals(EntityType.SPIDER), not the vehicle instance. Second, the bukkit entity needs to implement Vehicle, not the nms entity. You could create something extending CraftSpider that implements Vehicle and either set this.bukkitEntity in your constructor, or modify the getBukkitEntity() method to suit your needs.
     
    ColaCraft likes this.
  12. Offline

    ColaCraft

    Garris0n

    Thanks, I'll try that.

    When I make a custom BukkitEntity class, should I just extend it CraftSpider, and add it in to my enum, comparing the custom BukkitEntity to the actual BukkitEntity like it does the NMS classes?
     
  13. Offline

    Garris0n

    Yeah, just add your own entity in place of a normal one and have it implement Vehicle. Instantiate it the same way it's done in that static CraftEntity method used in .getBukkitEntity().
     
    ColaCraft likes this.
  14. Offline

    ColaCraft

    Garris0n

    Thanks! I will mark this thread as solved once I get the chance to test.
     
  15. Offline

    ColaCraft

    I'm still having a little trouble instantiating my CraftSpider class, does anyone know how?
     
Thread Status:
Not open for further replies.

Share This Page