Solved isAdult Bug?

Discussion in 'Plugin Development' started by Elimnator, Nov 19, 2014.

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

    Elimnator

    For some reason v.isAdult() where v is a Villager, returns true even when the villager is a baby.

    Can anyone help?
     
  2. Offline

    pookeythekid

    Elimnator Did you try it on any other animals to see if it's just coincidence?
     
  3. Offline

    Elimnator

    pookeythekid
    Yes, I tested with other mobs. It only doesn't work for villagers.

    How do I get if their a adult or not?
     
  4. Offline

    pookeythekid

    Elimnator I wouldn't have a clue... Villager implements the Ageable interface, which is where the .isAdult() method comes from... This may be a bug in this version of (Craft)Bukkit (depending on which one you build off of).
     
  5. Offline

    Elimnator

    Im just waiting for someone who knows to respond.
     
  6. Offline

    xTigerRebornx

    Elimnator All Ageable entites rely on the same code for handling the methods in the Ageable interface. Can you post the code you are using?
     
  7. Offline

    Elimnator

    xTigerRebornx
    Its very simple:
    Code:
            public void disguise(Villager v){
                //Baby Check
                if(v.isAdult() == false)
                    return;
                //Other code
            }
     
  8. Offline

    BetaNyan

    Try if (!v.isAdult())
     
  9. Offline

    Elimnator

    BetaNyan Thats not going to change anything if the value returns true.

    I am just checking the villagers hight to see if their old or not.
     
  10. Offline

    BetaNyan

    I do realize that, sometimes Eclipse glitched for me though and when I change the code it works. Assuming you're using Eclipse.
     
  11. Offline

    Elimnator

    BetaNyan
    "Eclipse glitched for you"? I was running the plugin on a bukkit server, how could Eclipse do anything?
     
  12. Offline

    Googlelover1234

    Elimnator
    Maybe he means somehow the Java compiler doesn't have enough magic from the code you provided, and he wants you to use his magical code.
     
  13. Offline

    BetaNyan

    No sometimes Eclipse doesn't save it correctly.
     
  14. Offline

    Asecta

    BetaNyan If eclipse didn't save it correctly I think it would have FAR more errors than just that. Besides, it's not eclipse that doesn't save it correctly, it is most likely you.

    I'm not sure about why it wont work for you, but perhaps you can mess around with metadata or with getAge() to try to predict if it is an adult or not. I'll look into it and make an edit when I find some information
     
  15. Offline

    BetaNyan

    Umm this isn't my problem xD. I am trying to help Elimnator.
     
  16. Offline

    Asecta

    BetaNyan I know... Hence why I put it under the line with your tag.
     
  17. Offline

    BetaNyan

    You tagged me and said it's most likely YOU"
     
  18. Offline

    Asecta

    BetaNyan No, but It doesnt really matter so lets not argue about it. The second part was for Elimnator.
     
  19. Offline

    Elimnator

    I just created this method, and it works fine:
    Code:
            public boolean isBaby(Villager v){
                if((v.isAdult() == false) || (v.canBreed() == false) || (v.getEyeHeight() < 1))
                    return true;
                return false;
            }
     
  20. Offline

    Tecno_Wizard

    Elimnator, your issue is likely an issue with your Bukkit build, and seeing Bukkit's current state, this cannot be fixed.
     
Thread Status:
Not open for further replies.

Share This Page