Sheep Monster Egg

Discussion in 'Plugin Development' started by titoscol, Jan 29, 2012.

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

    titoscol

    Hi,I have a problem, I havean"if"like this :
    Code:
    if (p.getItemInHand().getTypeId() == 383)
    But I wouldspecify onlysheepegg(id383:91).

    How?

    Thank you.
     
  2. Offline

    psanker

    You want to retrieve the metadata for item 383. Use this:

    Code:
    if (p.getItemInHand().getTypeId() == 383 && ((int) p.getItemInHand().getData()) == 91) {
        // Blah.
    } 
     
  3. Why even using getTypeId()? It's a lot easier and maintainable to check item.getType() against a Material.

    Code:JAVA
    1.  
    2. if(p.getItemInHand().getType() == Material.EGG)
    3. // do somethin
    4.  
     
  4. Offline

    iPhysX

    w00tklumpWn You can't get the seperate Eggs through Material.MONSTER_EGG
    I don't think. Not 100% sure.
     
  5. Offline

    titoscol

    Thank you guy, but I must put getData().getData() to make it work, i don't now if this is normal.

    @w00tklumpWn I don't now, I fint it more practice, i get it wrong?
     
  6. yea, you still have to check the data! Maybe create an seperate Enum for each possible type, just for beeing readable.

    It's not wrong actually, but uncomfortable! Like i said, you still have to check for the "right" egg type.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 23, 2016
Thread Status:
Not open for further replies.

Share This Page