Jump to content

[1.9] Register entities with spawn egg


SoggyMustache

Recommended Posts

I looked everywhere (I think) but I can't find anything on how to give my mobs spawn eggs I used this in 1.8 and it is telling me I need to change randomId to a string but that stilll doesnt make the egg work.

 

package net.soggymustache.zawam.entity;

import net.minecraft.entity.EntityList;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import net.soggymustache.zawam.ZAWAMain;
import net.soggymustache.zawam.entity.Warthog.EntityWarthog;

public class Entity {
public static int randomId;

public static void ZAWAMain(){
	registerEntity();
}
	 public static void registerEntity(){
//			 	createEntity(EntitySumatranRhinoceros.class, "SumatranRhinoceros", 0x424040, 
	 }

		public static void createEntity(Class entityClass, String entityName, int solidColor, int spotColor){
			randomId = EntityRegistry.findGlobalUniqueEntityId();

			EntityRegistry.registerGlobalEntityID(entityClass, entityName, randomId);
			EntityRegistry.registerModEntity(entityClass, entityName, randomId, ZAWAMain.modInstance, 42, 1, true);
			createEgg(randomId, solidColor, spotColor);

		}
		public static void createEgg(int randomId, int solidColor, int spotColor) {
			EntityList.entityEggs.put(String.valueOf(randomId), new EntityList.EntityEggInfo(randomId, solidColor, spotColor));

		}
	}

Link to comment
Share on other sites

Yes, but you're doing it wrong.

Stop using Global IDs.

As for the eggs, There are extra parameters for registering a mod entity with a egg.

We do it in a generic way without having to us Global IDs by using the entity name.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Link to comment
Share on other sites

    /**
     * Register the mod entity type with FML
     * This will also register a spawn egg.

     * @param entityClass The entity class
     * @param entityName A unique name for the entity
     * @param id A mod specific ID for the entity
     * @param mod The mod
     * @param trackingRange The range at which MC will send tracking updates
     * @param updateFrequency The frequency of tracking updates
     * @param sendsVelocityUpdates Whether to send velocity information packets as well
     * @param eggPrimary Primary egg color
     * @param eggSecondary Secondary egg color
     */
    public static void registerModEntity(Class<? extends Entity> entityClass, String entityName, int id, Object mod, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates, int eggPrimary, int eggSecondary)
    {
        instance().doModEntityRegistration(entityClass, entityName, id, mod, trackingRange, updateFrequency, sendsVelocityUpdates);
        EntityRegistry.registerEgg(entityClass, eggPrimary, eggSecondary);
    }

Reading helps... Its straight forward. Also UPDATE to 1.10!

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

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.

Guest
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.