Detecting which fish are in a chest

Discussion in 'Plugin Development' started by RebzO1, Aug 25, 2014.

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

    RebzO1

    I am having trouble with this
    and the only part which is wrong is
    Code:java
    1. if (i.getType() == Material.RAW_FISH, (short) 2){
    2. points = points + (i.getAmount() * 3);
    3. clown = clown + i.getAmount();
    4. }


    Forgot to mention what the errors were.

    Error 1
    Syntax error on token "RAW_FISH", * expected after this token

    Error 2
    The operator * is undefined for the argument type(s) Material, short

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 10, 2016
  2. Offline

    St3venAU

    getType() returns just the Material, not the data. You need to check both seperately:
    Code:java
    1. if(i.getType() == Material.RAW_FISH && i.getData().getData() == (byte) 2)
     
  3. Offline

    RebzO1

    nvm fixed

    Code:java
    1. if (i.getType() == Material.RAW_FISH && i.getDurability() == 2){
    2. points = points + (i.getAmount() * 4);
    3. clown = clown + i.getAmount();
    4. } else if (i.getType() == Material.RAW_FISH && i.getDurability() == 3){
    5. points = points + (i.getAmount() * 3);
    6. puffer = puffer + i.getAmount();
    7. } else if (i.getType() == Material.RAW_FISH && i.getDurability() == 1){
    8. points = points + (i.getAmount() * 2);
    9. salmon = salmon + i.getAmount();
    10. } else if (i.getType() == Material.RAW_FISH){
    11. points = points + i.getAmount();
    12. fish = fish + i.getAmount();
    13. }


    maybe yours was the correct way to do it (i tried it after mine) however the way i did it doesnt have deprecation warnings
     
  4. Offline

    FabeGabeMC

    RebzO1
    also instead of doing fish = fish + number just do fish += number
     
  5. Offline

    St3venAU

    RebzO1
    Durability is stored as the data value so they are both the same thing really.
     
Thread Status:
Not open for further replies.

Share This Page