Solved Cannot pickup custom ItemStack

Discussion in 'Plugin Development' started by elementalgodz11, Apr 5, 2014.

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

    elementalgodz11

    So I've tried to drop an egg of the entity damaged using the EntityDamageByEntity event,

    Firstly, I used the .getData() method to get the egg type, which worked but was deprecated. So I went for an alternative solution, create the custom egg itemstack. I have done this and now when the ItemStack is spawned on the ground { it cannot be picked up, and ItemPickup event is not cancelled }

    Here is the code:
    Code:
    Entity caught = event.getEntity();
     
    caught.remove();
     
    EntityType entityType = caught.getType();
    SpawnEgg spawnEgg = new SpawnEgg();
    spawnEgg.setSpawnedType(entityType);
    ItemStack spawnedEgg = spawnEgg.toItemStack();
    Bukkit.getServer().getWorld("world").dropItemNaturally(caught.getLocation(), spawnedEgg);
     
  2. The getData() is deprecated, but you van just use it.
     
Thread Status:
Not open for further replies.

Share This Page