Create Spawn Egg ItemStack

Discussion in 'Plugin Development' started by PogoStick29, Jul 28, 2013.

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

    PogoStick29

    I am having trouble creating a spawn egg using this code:

    Code:
    for (EntityType e : EntityType.values()) {
        if (e.isAlive()) {
            SpawnEgg egg = new SpawnEgg(e);
            ItemStack i = new ItemStack(egg.getItemType(), 1);
            i.setData(egg);
            inv.addItem(i);
        }
    }
    All this code does is spawn 30 generic mob eggs in one stack.
     
  2. Offline

    xTrollxDudex

  3. Offline

    PogoStick29


    The method setData(MaterialData) in the type ItemStack is not applicable for the arguments (byte)
     
  4. Offline

    Huntiz

    I was using it with this:
    Code:java
    1. final Item item = player.getWorld().dropItem(player.getEyeLocation(), new ItemStack(Material.SpawnEgg));
    2. item.setVelocity(player.getLocation().getDirection().multiply(2));
     
  5. Offline

    xTrollxDudex

  6. Offline

    DevRosemberg

    Sorry for resurrecting an old thread but:

    Code:java
    1. ItemStack stack = new ItemStack(Material.MONSTER_EGG, 1, EntityType.WOLF.getTypeId());


    Is what you should use.
     
Thread Status:
Not open for further replies.

Share This Page