ItemSpawning | ItemStack (Specific Location)

Discussion in 'Plugin Development' started by M&R Coding, Jul 9, 2015.

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

    M&R Coding

    So basically what I am wanting to do is spawn items at a specific location so say I placed down Obsidian, I would want items to spawn ontop of that block like tnt items for example. Not the actual block but items you can pick up. So if I placed an obsidian block anywhere on the map, as long as it would have an empty space above it, tnt items would start to spawn there. This is what I've written so far so correct me or completely recode it if its completely wrong and all irrelevant. I've replaced some of the areas with [TEXT] to make it easier to understand. Thank you for your time. Much appreciated if answered!
    - Matt

     
  2. Offline

    SuperSniper

    Code:
    public void onBlockPlace(BlockPlaceEvent e) {
    Player player = e.getPlayer();
    if (e.getBlock().getType() == Material.OBSIDIAN) {
    if(player.isOp()) {
    player.sendMessage([MESSAGE]);
    Location BLock= e.getBlock().getLocation().add(0, 1, 0).getBlock();
    World world = e.getBlock().getWorld();
    ItemStack blocklocation = new ItemStack(Material.OBSIDIAN);
    BLock.getWorld().dropItem(BLock ,new ItemStack(Material.TNT));
    
     
  3. Try using .dropItem() instead of dropItemNaturally().
     
  4. Offline

    M&R Coding

    http://gyazo.com/f6f1c2d0a3cf8b0f2e859af542e5a9f0 < I comes up with tons of errors
     
  5. @SuperSniper Please do not spoonfeed and follow naming conventions.

    @M&R Coding Yes there are errors in that spoonfeed.

    Just check for a place then drop an item a block above.
     
  6. Offline

    M&R Coding

    Is there any chance you could help because this is the one part that is really confusing me with what I have to do?
     
  7. @M&R Coding
    I will not spoonfeed but I will help where I can.
     
  8. To get the middle of the block above location:
    block.getLocation().add(0.5, 1.5, 0.5);
    Then just world.dropItem(location, itemstack
     
Thread Status:
Not open for further replies.

Share This Page