The uncraftable SpawnEgg!

Discussion in 'Plugin Development' started by nathanaelps, Sep 13, 2012.

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


    In short:
    Creating plugin: Craftable spawn eggs! (I know it's been done before)

    I successfully create recipes for spawn eggs. Let's try one that uses stone:

    Material xpBottle = Material.getMaterial(384); //<-Bottle O' Enchanting
    Material stone= Material.getMaterial(1); //Stone
    int count = 1;
    //set up the egg itself
    SpawnEgg theEgg = new SpawnEgg();
    String output = ZOMBIE;
    ItemStack eggType = theEgg.toItemStack();
    //And, create the recipe!
    ShapelessRecipe eggRecipe = new ShapelessRecipe(eggType);
    eggRecipe.addIngredient(count,  stone);
    Lay 1 stone and 1 Bottle O' Enchanting on a crafting table, viola! a Zombie Spawn Egg pops up on the output!
    Wonderful. Perfect. Delightful.
    Now, try to pick up said egg...
    "Disconnected by Server" and "Internal server error"
    The server is busy crying:
    14:47:50 [WARNING] Failed to handle packet: java.lang.NullPointerException
            at net.minecraft.server.SlotResult.c(SourceFile:41)
            at net.minecraft.server.SlotResult.b(SourceFile:58)
            at net.minecraft.server.Container.clickItem(
            at net.minecraft.server.NetServerHandler.a(
            at net.minecraft.server.Packet102WindowClick.handle(SourceFile:29)
            at net.minecraft.server.NetworkManager.b(
            at net.minecraft.server.NetServerHandler.d(
            at net.minecraft.server.ServerConnection.b(SourceFile:35)
            at net.minecraft.server.DedicatedServerConnection.b(SourceFile:30)
            at net.minecraft.server.MinecraftServer.q(
            at net.minecraft.server.DedicatedServer.q(
            at net.minecraft.server.MinecraftServer.p(
    What the heck am I doing wrong?!
  2. Offline


    Is it whole error?
  3. Offline


    Yeah, that's everything.
  4. Offline


    I can confirm that error too. It looks like that the spawner egg in the result slot cause the error, other items like golden apple works without any problems.
  5. Offline


    Fun fact:
    ItemStack eggType = theEgg.toItemStack();
    has the problem, while

    ItemStack eggType = new ItemStack(383, 1, (short) 120);
    does not. Guess I'll tinker some more.
    (Am I using SpawnEgg.toItemStack() wrong?)[/CODE]

    Yep. Did some more tinkering:

    ItemStack eggType = theEgg.toItemStack(1);
    fixes it. You need the amount.
    Which isn't what says, so I should probably figure out how to turn in a bug report...
    Anyone know how to do that?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 28, 2016
  6. Offline


    It's in the javadocs

    ItemStack toItemStack (int amount)
    Creates a new ItemStack based on this MaterialData.
  7. Offline


    Yes, but so is

    ItemStack org.bukkit.material.MaterialData.toItemStack ( )
    Creates a new ItemStack based on this MaterialData.

    which doesn't work. I just figure that the toItemStack() without a parameter should be removed from the jd.
  8. Offline


  9. Offline


    Yep. That would do it.
    Is it standard to make the default stack size be 0? I would think that it would default to 1, so that it doesn't crash the client.
  10. Offline


    I believe you can still use it, just not actually give it to the user. As for the specifics, I can only speculate but it is always annoying when you work on a problem for a while just to find out that if you RTM then the solution is staring right back at you lol.
Thread Status:
Not open for further replies.

Share This Page