Solved Spawn item on method start?

Discussion in 'Plugin Development' started by Felixx61, Jun 4, 2013.

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

    Felixx61

    Good evening all,

    I'm trying to create a method that spawns an item above a saved block the player chooses when the "Play" method is called. I think in order to save block(s) you have to create a Map and save the players location?

    Any thoughts?

    Thank-you
     
  2. Offline

    chasechocolate

    Well to spawn an item above a block, use this bit of code:
    Code:java
    1. Location loc = block.getLocation().add(0, 1, 0);
    2. ItemStack item = <the item to drop>;
    3. loc.getWorld().dropItem(loc, item);

    I added 1 to the Y of the block because if you didn't, it would spawn in the block and will look buggy.
     
    Felixx61 likes this.
  3. Offline

    Felixx61


    Thanks very much, I've hooked it in successfully.
     
Thread Status:
Not open for further replies.

Share This Page