Solved Add a colour and check the block

Discussion in 'Plugin Development' started by user_91277742, Apr 14, 2018.

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

    user_91277742

    Hello there!
    So i'm trying to add a colour to a ItemStack Wool but i tried a lot of ways and without solve.
    Here the code
    Code:
        public ItemStack ball() {
            ItemStack ball = new ItemStack(Material.WOOL);
            return Quaffle;
        }
        @SuppressWarnings("unlikely-arg-type")
        @EventHandler
         public void onBlockDamage(BlockDamageEvent e) {
            Player p = e.getPlayer();
            if(e.getBlock().getType().equals(ball())) {
                p.sendMessage("You hit the ball!");
            }
        }
    
     
  2. @Ahrigumi
    Do
    ItemStack ball = new ItemStack(Material.WOOL, DyeColor.RED.getWoolData());
    and don't do
    e.getBlock.getType().equals(ball())

    try this

    Block b = e.getBlock();
    if(b.getType() == Material.WOOL)
    {
    Wool block = (Wool) b;
    if(block.getColor() == DyeColor.RED)
    {

    }
    }
     
  3. Offline

    MightyOne

    Just some things that make no sense for me:
    You create one ItemStack ball, a white wool block, but you return a totally different object? why?

    Her you are about to compare a Material with an ItemStack. That will return true ever.
    And @SuppressWarnings("unlikely-arg-type") alread ytells you that.

    As always this problem is not new at all and there already exist severeal threads about it:
    How do I check what color a wool block is?

    Check and set ColoredWool
     
Thread Status:
Not open for further replies.

Share This Page