Get Specific Wool Color HELP!

Discussion in 'Plugin Development' started by RoBaMe, Jul 2, 2015.

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

    RoBaMe

    Hello!
    I'm developing a plugin that when a player left clicks a lime wool, he speed up. and when he left clicks on a red wool, he slow down. I need to check if it's a lime wool or a red wool but i can't figure how to check the color of the wool because it does only material.WOOL and not material.LIME/RED WOOL
    PLZ HELP!
     
  2. if your'e using a block:
    block.getData()
    if you're using an item:
    item.getData().getData()

    lime wool data value is 5
    red wool data value is 14
     
  3. Offline

    RoBaMe

    this is my code so where do i put the block.getData()?
    Code:
    public void SU(PlayerInteractEvent u){
            if(u.getAction() == Action.LEFT_CLICK_BLOCK){
                Block b = u.getClickedBlock();
                if(b.getType() == Material.WOOL){
    
    
                      
                    }
                  
                }
    i tried to do this but it gave me an arror
    Code:
    if(b.getType() == Material.WOOL){
                        if(b.getData() == 5){
                           
                        }
                    }
     
  4. @RoBaMe Try this:
    Code:
    if (block.getType() == Material.WOOL) {
        Wool wool = new Wool(block.getType(), block.getData());
    if (wool.getColor() == DyeColor.GREEN) {
        // Apply speed
        } else if (wool.getColor() == DyeColor.RED) {
        // Apply slowness
        }
    }
    That should work. Haven't tested it, though. If you need any more help just tag me.
     
  5. Offline

    RoBaMe

    getData cannot be resolved or is not a field

    now im getting two warnings - The constructor Wool(Material, byte) is deprecated and - the method getData() from the type Block is deprecated and it crosses a line on wool and getData
     
    Last edited by a moderator: Jul 2, 2015
  6. Offline

    RoBaMe

    in actually doing this with ints so this is my code now :
    Code:
    public void SU(PlayerInteractEvent u){
            if(u.getAction() == Action.LEFT_CLICK_BLOCK){
                Block b = u.getClickedBlock();
                if (b.getType() == Material.WOOL) {
                    Wool wool = new Wool(b.getType(), b.getData());
                if (wool.getColor() == DyeColor.LIME) {
                    VS = VS + 1;
                    }
                else if (wool.getColor() == DyeColor.RED) {
                    VS = VS - 1;
                    }
                }
                           
            }
        }
     
  7. @RoBaMe
    1. What's wrong with it..?
    2. What is VS?
     
  8. Offline

    RoBaMe

    @CodePlaysMinecraft VS is the int, and i said already : now im getting two warnings - The constructor Wool(Material, byte) is deprecated and - the method getData() from the type Block is deprecated and it crosses a line on wool and getData
     
  9. @RoBaMe Deprecation doesn't mean that it doesn't work. It just means that the method might be removed in a future version. The code still works.
     
  10. Offline

    RoBaMe

    @CodePlaysMinecraft ok thx! :D

    @CodePlaysMinecraft i have another question in LEFT_CILCK_BLOCK the .getClickedBlock in getting the block i clicked with or the block i clicked on? like if it was in my inventory and i right click with him or i right clicked on a lime/red wool in the world?

    EDIT by Timtower: merged posts
     
    Last edited by a moderator: Jul 2, 2015
Thread Status:
Not open for further replies.

Share This Page