Block - ideal tool?

Discussion in 'Plugin Development' started by thechrisanator, Nov 14, 2018.

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

    thechrisanator

    Is there a way to get a block's ideal mining tool?

    currently, I have it as this:

    Code:
    if(block.getType() == Material.DIRT || block.getType() == Material.SAND || block.getType() == Material.GRAVEL ||
                                       block.getType() == Material.GRASS || block.getType() == Material.GRASS_PATH || block.getType() == Material.CLAY ||
                                       block.getType() == Material.SNOW || block.getType() == Material.SNOW_BLOCK || block.getType() == Material.MYCEL) {
                                      
                                        System.out.println("shovel");
    what I'd prefer, is:

    if (block.getIdealTool()) == "Shovel"
    or something like that.

    is this possible? or must I go through every single block as Im doing above?

    Thanks
     
  2. Online

    timtower Administrator Administrator Moderator

  3. Offline

    thechrisanator

    so this is the only way to get the ideal tool for the job? @timtower
    do you think theyll ever make that an attribute of Block?
    and alright, thanks :)
     
  4. Online

    timtower Administrator Administrator Moderator

    @thechrisanator I know that the client handles it, not sure how though.
     
  5. Offline

    thechrisanator

    Also, say I wanted to use a for loop instead and store all the Material types in a list.
    how would I do that?

    and where would I initialize the list of Materials? @timtower
     
  6. Online

    timtower Administrator Administrator Moderator

    @thechrisanator That list can be anywhere.
    Loop over it and check if it contains the material.
    And you would need multiple lists. One for each tool.
     
Thread Status:
Not open for further replies.

Share This Page