Problem with ItemStack monster egg

Discussion in 'Plugin Development' started by MartinPL, Feb 12, 2018.

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

    MartinPL

    Hi! I'm going to make plugin, when you broke mob spawner = you get one and you get monster egg.
    And i have problem with ItemStack, because it's giving to me one spawn egg. But it's white. That's my code:


    Code:
    Block b = event.getBlock();
    
    CreatureSpawner spawner = ((CreatureSpawner)b.getState());
               
                short typeID =  (short) spawner.getSpawnedType().ordinal();
               
                ItemStack egg = new ItemStack(Material.MONSTER_EGG, 1, typeID);
     
  2. @MartinPL
    Change it to this

    short typeID = (short) spawner.getSpawnedType().getTypeId();
     
  3. Code:
    Block b = event.getBlock();
    
    CreatureSpawner spawner = ((CreatureSpawner)b.getState());
             
                ItemStack egg = new ItemStack(Material.MONSTER_EGG, 1, (byte) 999);
    Instead of the "999" u have to put sub ID of the spawn egg. For example if you wanna have a creeper spawn egg:
    Code:
    Block b = event.getBlock();
    
    CreatureSpawner spawner = ((CreatureSpawner)b.getState());
             
                ItemStack egg = new ItemStack(Material.MONSTER_EGG, 1, (byte) 50);
     
  4. @baenii
    I think he understands that but he doesn't want to put in the id manually, he wants to get the id from the spawner and didn't know the method to do that, with my response it gives the id of the mob from the spawner
     
Thread Status:
Not open for further replies.

Share This Page