[unsolved] falling gravel and [solved] block to item

Discussion in 'Plugin Development' started by redspider, Apr 9, 2011.

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

    redspider

    i guess it's really easy, but i really can't find the function for it:
    how can i turn a block into an item?
     
  2. Offline

    ssell

    @redspider

    There is no single method call that changes a block into it's respective item.

    Do you want to add it to the inventory? Or do you want it to appear in the world at the location of the block (like if you just destroyed it?)

    If the former:
    Code:
    player.getInventory( ).addItem( new ItemStack( theBlock.getType( ), 1 ) );
    
    the latter:
    Code:
    Material material = block.getType( );
    
    block.setType( Material.AIR );
    block.getWorld( ).dropItem( block.getLocation( ), new ItemStack( material, 1 ) );
    
     
  3. Offline

    redspider

    @ssell
    thank you

    there is another problem, i'm facing: how can i create an falling sand / gravel entity?
     
Thread Status:
Not open for further replies.

Share This Page