Jump to content

[1.9.4] Adding vanilla spawn eggs to crafting recipes


Recommended Posts

Hello all, I've thoroughly scoured the internet to the best of my abilities as to how to add vanilla spawn eggs to crafting recipes, but can't seem to figure it out - most results are concerning just adding custom spawn eggs to the game, which is not what I'm trying to do; other results that were semi-helpful mostly were incomplete answers or for a much earlier version.


I've tried adding the data value to the ItemStack object, for example:


ItemStack spawnEgg_zombie = new ItemStack(Items.SPAWN_EGG, 1, 54);


But all that gives me is a generic spawn egg.


I know giving a player a zombie spawn egg in game requires the command:


/give <PLAYER> minecraft:spawn_egg 1 0 {EntityTag:{id:Zombie}}


So I figure I need to make use of the initializer for an ItemStack object that requires an "NBTTagCompound". However the part that I'm confused at is nesting the tags to produce a result similar to the in-game command (assuming that this is the correct way to go about this). I've tried various different things using NBTTagCompound variables, but none of them seemed to give me anything but a generic spawn egg.


If any help could be given, I'd greatly appreciate it! :)

Link to comment
Share on other sites

Create the




, then call


to set the


's spawned entity ID.


Look at the implementation of this method to see how it produces the same NBT structure as you'd use in the command.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

By using this site, you agree to our Terms of Use.