dropItem / dropItemNaturally bounces

Discussion in 'Spigot Plugin Development' started by SteveBob, May 14, 2016.

  1. Hey guys,

    Seems like nobody else on the internet has this issue except me, forever.

    Take a BlockBreakEvent, get the location and spawn an ItemStack at the location. 99% of the time, the ItemStack will just fly away, regardless of whether it's dropItem or dropItemNaturally.

    Take this:

    Code (Text):
    Bukkit.getWorld(GameConfig.getMap()).dropItem(blockBreakLocation, new ItemStack(Material.DIAMOND));
    Obviously the code links in with other things such as my getMap() method and my location for the block break event.

    I've had this issue literally forever, and it very well may be something dumb that I'm doing, it probably is. It seems to be if the block that is broken is next to other blocks or basically just not on flat land, where the spawned ItemStack will fly off in any random direction.

    I've tried a lot of things, even:

    Code (Text):
                    Item one = player.getWorld().dropItem(blockBreakLocation.add(0, 0.5, 0), ITEM_STACK);
    Any help? I need the item to drop just as if it was a piece of cobblestone coming out of a stone block.
  2. Crazy guess, but try this:

    Code (Text):
    Item i = p.getWorld().dropItem(p.getLocation(), new ItemStack(Material.APPLE));
    edit: didnt read the whole post -.-
  3. Ok so here are 2 things:
    1. BlockBreakEvent is fired before block actually breaks. Meaning the moment you spawn an item, the block is still there. The block will interfere the dropped item. Try dropping the item with a delay of 0 tick (at next tick).
    2. The location you use in the BlockBreakEvent should .add(0.5, 0, 0.5) because the location are starting coordinate of a block adding 0.5 to x and z will make it centered. Try xxxxx.getLocation().add(0.5, 0, 0.5)