add Items to Inventory

Discussion in 'Plugin Development' started by Zero9195, Feb 3, 2011.

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

    Zero9195

    so now, I give up. I tried hours to give the player an Item after the BlockDamagedEvent bt nothing works. Maybe you can help me out.
    Want to give a Player a block they attacked. It is going to be a wool block, so the same colour would be nice too.
    After that, the attacked block should be destroyed.

    I failed in everything so pls help me
    Zero9195
     
  2. Offline

    Plague

    First just program it to give an item to the player.
    Code:
    ItemStack stack = new ItemStack(id, count, damage);
    player.getInventory().addItem(stack);
    you set the color by the damage argument, use values from wiki or javadoc
     
  3. Offline

    Zero9195

    Oh nooooooooo, I'm too sttupid for this World. I just forgot the "new" before "ItemStack".... Thanks, big thanks ;)

    Can I get the Damage from the Block which is attacked? because else I can't give the Players the right Blocks...
     
  4. Offline

    Plague

    Well I never coded a BlockListener, but there is an "onBlockDamage(BlockDamageEvent event)" and then you should be able to do "event.getBlock().getData()", which should return the metadata of the block. I know you want actually the damage value, but I think bukkit encapsulates that a returns the right value (at least for wool in hand it is called data also, so just try that).
     
  5. Offline

    Zero9195

    ok I will try that, post here if it doesn't work ;)
    Thanks ;)
     
Thread Status:
Not open for further replies.

Share This Page