getItemStack, how?

Discussion in 'Plugin Development' started by Errored, Feb 21, 2013.

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

    Errored

    How do I get an ItemStack of item? Specifically an Emerald? Sorry for the noob questions, would be extremely helpful to be pointed in the right direction. I know about the getItemStack() method but I can't seem to find the proper way to use it. This is how I'm using it for:

    Code:
    public void onBlockBreak(BlockBreakEvent event) {
      final Block origin = event.getBlock();
      final int type = origin.getTypeId();
      if (type == 31) {
        event.getPlayer().getWorld().dropItem(ItemStackHere);
        // how do I get the ItemStack of an Emerald?
        // getItemStack() ???
      }
    }
    
    I'm stuck and any help is appreciated.
     
  2. Offline

    ZeusAllMighty11

    Here you go, enjoy:

    Code:
    @EventHandler
    public void onBlockBreak(BlockBreakEvent event) {
      final Block origin = event.getBlock();
      final int type = origin.getTypeId();
      if (type == 31) {
        event.getPlayer().getWorld().dropItem(new ItemStack(Material.EMERALD, 1));
      }
    }
    
     
  3. Offline

    chasechocolate

    Code:java
    1. ItemStack emerald = new ItemStack(Material.EMERALD);
     
  4. Offline

    Errored

    Thanks! :3
     
Thread Status:
Not open for further replies.

Share This Page