Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • How to get a spawn egg as item?
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 0
Dustpuppy

How to get a spawn egg as item?

By Dustpuppy, September 17, 2017 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

Dustpuppy    1

Dustpuppy

Dustpuppy    1

  • Creeper Killer
  • Dustpuppy
  • Members
  • 1
  • 120 posts
Posted September 17, 2017

I am searching now for ages, how to get a specified spawn egg.

What ever i try, i only get a white spawn egg, that can't spawn anything.

Here's what i've tried at last.

Spoiler

	public static Item spawnEgg = getSpawnEgg();
	public static Item getSpawnEgg()
	{
		ItemStack stack = new ItemStack(Items.SPAWN_EGG, 1);
        ItemMonsterPlacer.applyEntityIdToItemStack(stack, "thewizardmod.MiniZombie");
		return stack.getItem();
	}

 

 

  • Quote

Share this post


Link to post
Share on other sites

Choonster    1651

Choonster

Choonster    1651

  • Reality Controller
  • Choonster
  • Forge Modder
  • 1651
  • 5097 posts
Posted September 17, 2017

An Item instance only represents an item type, in this case the spawn egg. To store any more data (e.g. the entity spawned by the egg), you need the metadata/NBT of an ItemStack.

 

You create an ItemStack with the NBT data required to spawn a "thewizardmod.MiniZombie" entity but then immediately discard it by returning the Item from the method rather than the ItemStack.

 

Which version of Minecraft are you using?

 

If you're using 1.9-1.11.2, ItemMonsterPlacer.applyEntityIdToItemStack is a client-only method that can't be used from common code.

 

If you're using 1.11+, "thewizardmod.MiniZombie" is in the wrong format for a mod entity's registry name; it's a ResourceLocation so it should be lowercase and in the format "modid:entity_name".

  • Quote

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.

Share this post


Link to post
Share on other sites

Dustpuppy    1

Dustpuppy

Dustpuppy    1

  • Creeper Killer
  • Dustpuppy
  • Members
  • 1
  • 120 posts
Posted September 17, 2017

It's MC 1.10.2

I don't need the ItemStack. I need the Item it self. What else to do, then stack,getItem() to get it?

 

  • Quote

Share this post


Link to post
Share on other sites

Choonster    1651

Choonster

Choonster    1651

  • Reality Controller
  • Choonster
  • Forge Modder
  • 1651
  • 5097 posts
Posted September 17, 2017
8 minutes ago, Dustpuppy said:

It's MC 1.10.2

I don't need the ItemStack. I need the Item it self. What else to do, then stack,getItem() to get it?

 

The Item is just "Spawn Egg". If you want "Spawn Egg of Mini Zombie", you need an ItemStack.

  • Quote

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.

Share this post


Link to post
Share on other sites

Dustpuppy    1

Dustpuppy

Dustpuppy    1

  • Creeper Killer
  • Dustpuppy
  • Members
  • 1
  • 120 posts
Posted September 17, 2017

Shit. Then i have to find another way to give player an item he can use to spawn the entity. Don't want to rewrite the whole crafting code, i have.

 

  • Quote

Share this post


Link to post
Share on other sites

Dustpuppy    1

Dustpuppy

Dustpuppy    1

  • Creeper Killer
  • Dustpuppy
  • Members
  • 1
  • 120 posts
Posted September 17, 2017

Is there a way to make an item from an entity? Then i could give the player this to spawn the entity.

 

  • Quote

Share this post


Link to post
Share on other sites

Choonster    1651

Choonster

Choonster    1651

  • Reality Controller
  • Choonster
  • Forge Modder
  • 1651
  • 5097 posts
Posted September 17, 2017
Just now, Dustpuppy said:

Is there a way to make an item from an entity? Then i could give the player this to spawn the entity.

 

You'd have to make your own Item like the spawn egg that only spawns one entity type rather than whatever's specified in the NBT.

 

I'd recommend reworking your code to use an ItemStack rather than just an Item.

  • Quote

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.

Share this post


Link to post
Share on other sites

Draco18s    2402

Draco18s

Draco18s    2402

  • Reality Controller
  • Draco18s
  • Members
  • 2402
  • 15921 posts
Posted September 17, 2017

Yes, it's an ItemStack(SpawnEgg) with NBT data indicating what entity to spawn.

  • Quote

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Share this post


Link to post
Share on other sites

jredfox    2

jredfox

jredfox    2

  • Dragon Slayer
  • jredfox
  • Members
  • 2
  • 660 posts
Posted September 17, 2017 (edited)

You could try either making your own spawn egg and look at my code. if you copy and paste give me credit.

https://github.com/jredfox/silkspawners/tree/master/src/main/java/com/EvilNotch/silkspawners

 

Or you could download silk spawners mod which already adds in eggs to the creative tab for missing eggs your choice. Note it might add eggs for 1.9+ that are not there as it's not fully tested with the new egg system but, still should work.

https://minecraft.curseforge.com/projects/silk-spawners-forge-edition

Edited September 17, 2017 by jredfox
adding text
  • Quote

Share this post


Link to post
Share on other sites

Dustpuppy    1

Dustpuppy

Dustpuppy    1

  • Creeper Killer
  • Dustpuppy
  • Members
  • 1
  • 120 posts
Posted September 17, 2017

Too late. Have made an item, that can be crafted on the altar and used to spawn the zombie. This little zombies are like golems. They can do stupid work, but have no brain for more. Like politics xD

wJOosx2.png

4TlNQXM.png

INkV4mi.png

  • Quote

Share this post


Link to post
Share on other sites

Draco18s    2402

Draco18s

Draco18s    2402

  • Reality Controller
  • Draco18s
  • Members
  • 2402
  • 15921 posts
Posted September 17, 2017

Why does its inventory icon look rotated?

  • Quote

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Share this post


Link to post
Share on other sites

Dustpuppy    1

Dustpuppy

Dustpuppy    1

  • Creeper Killer
  • Dustpuppy
  • Members
  • 1
  • 120 posts
Posted September 17, 2017

Because i rotated it. Flat was yesterday :P

  • Quote

Share this post


Link to post
Share on other sites

Draco18s    2402

Draco18s

Draco18s    2402

  • Reality Controller
  • Draco18s
  • Members
  • 2402
  • 15921 posts
Posted September 17, 2017

Completely breaks the minecraft aesthetic.

  • Like 1
  • Quote

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 0
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • poopoodice
      Adding jar files to existing environment

      By poopoodice · Posted 14 minutes ago

      It's been discussed for a long time, but none of the solutions worked for me (maybe I did not did them right). So I have created another mod (basically a tool) and I want to use it in another environment, this is what I've tried:   1. run normal build ./gradlew.bat build, and then put built jar from lib into the mods folder. 2. run jar build ./gradlew.bat jar, and then put built jar from reobfJar into the mods folder. 3. build jar using existing ide options, and then put built jar from lib into the mods folder.   1 & 2 causes crashes, and 3 does not work at all (not detected).   What is the correct way of doing it in 1.16.4? Thanks.
    • Draco18s
      GUI Documentation

      By Draco18s · Posted 40 minutes ago

      GUIs aren't that difficult. There's dozens of tutorials for them and they haven't really changed all that much in ten years.
    • Xenfo
      Mod Blocker

      By Xenfo · Posted 56 minutes ago

      Any mod blockers that actually work? Please link them if yes.
    • diesieben07
      Tessellator ignores lighting?

      By diesieben07 · Posted 1 hour ago

      Neither 1.10 now 1.14 are supported here. Please refer to the supported versions page: https://forums.minecraftforge.net/topic/91712-supported-version-directory/
    • CookieLukas
      Tessellator ignores lighting?

      By CookieLukas · Posted 1 hour ago

      Oh,  sorry, the code was 1.10.2, but as its not allowed here, I updated it to 1.14.4.
  • Topics

    • poopoodice
      0
      Adding jar files to existing environment

      By poopoodice
      Started 14 minutes ago

    • T1ps
      3
      GUI Documentation

      By T1ps
      Started Tuesday at 10:14 PM

    • Xenfo
      0
      Mod Blocker

      By Xenfo
      Started 56 minutes ago

    • CookieLukas
      3
      Tessellator ignores lighting?

      By CookieLukas
      Started 2 hours ago

    • Extrodonary
      1
      Forge isn't working on Minecraft Realms

      By Extrodonary
      Started 1 hour ago

  • Who's Online (See full list)

    • Luis_ST
    • Pinary
    • byel3606
    • arch12
    • StealthyNoodle
    • bananapizzuh
    • Xenfo
    • Warsade
    • monkeysHK
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • How to get a spawn egg as item?
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community