dropItem and dropItemNaturally bugged?

Discussion in 'Plugin Development' started by SteveE104, Jan 20, 2011.

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


    Hello all.

    I've been writing some simple plugins, and my latest involves changing the way blocks are broken.
    Basically, I check if the block is in the "Digging" state, then set it's typeId too 0. I then use dropItems in the blocks location. The items all drop the way I want them to, but when I pick them up, the block can not be placed, and disappears from my inventory if I try.

    Is there a workaround to fix this, or am I missing something.
  2. Offline


    It works fine, post your code?
  3. Offline


    This is just one of my functions, but it behaves the same as the others. Everything works fine, but the dropped items are not acting like blocks broken in a regular fashion.

        public void goldPick(BlockDamageEvent click) {
            check = click.getBlock().getTypeId();
            toolId = click.getPlayer().getItemInHand().getTypeId();
            ItemStack tool = click.getPlayer().getItemInHand();
            state = click.getDamageLevel().toString();
            if (check == 1 && state == "DIGGING" && toolId == 285) {
                tool.setDamage((byte) (tool.getDamage() + 1));
                click.getPlayer().getWorld().dropItemNaturally(new Location (click.getBlock().getWorld(), click.getBlock().getX(), click.getBlock().getY(), click.getBlock().getZ()), new ItemStack (4));
                if (tool.getDamage() == (byte) 192) {
    And here is the plugin if anyone wants to try it out for me...

    Golden Ax, Pick, and Shovel are ready, and I might do the Sword and Hoe if I think they would be of any use.

    -Golden Ax breaks all logs above the one you break, has the default number of uses.
    -Golden Pick breaks smooth stone at a very fast rate, has 192 uses.
    -Golden Shovel breaks grass, dirt, soil, sand and gravel at a very fast rate, also has 192 uses.

    Though nothing dropped seems to work at the moment....

    Any other plugins I could check out that use the dropItems method.
    I've tried iStick, but the item drops have been disabled, perhaps it is having the same problem?

    Attached Files:

    Last edited by a moderator: May 6, 2016
  4. Offline


    event.getPlayer().getWorld().dropItemNaturally(event.getPlayer().getLocation(), new ItemStack(MATERIAL.IRON, 1));
  5. Offline


    Thank you! It's working great! :D

    I could call it a 1.0 release now!

    I'll post it here, and put one on the release board as well.

    Attached Files:

  6. Offline


    :p good job :D
  7. Offline

    Chuck Lieb

    event.getPlayer().getLocation() should be the location of the block, not the player, yes?
  8. Offline


    If you wanted it to drop from the block instead of the player I would assume
    would work
  9. Offline


    Yes, I used event.getBlock().getLocation() so the drop spawns from the blocks location as it would regularly. Though spawning a drop at the players location could have its own uses...
Thread Status:
Not open for further replies.

Share This Page