Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[SOLVED][1.8] Custom Mod not Natural Spawning


Recommended Posts

Hello,

I have a custom mod which, I have registered the renderer, egg and entity for natural spawning, however, I have yet to see it actually spawn.  I have it set in the same way as a vanilla mob (zombie).  (The egg and renderer works, just not natural spawn).

 

@EventHandler
public void init(FMLInitializationEvent event) {
        // get next available id
int mobId = 0;
        do {
            mobId++;
        } while(EntityList.getClassFromID(mobId) != null);

registerModEntityWithEgg(GhoulEntity.class, "Ghoul", mobId, 0x3F5505, 0x4E6414);
// register entities for natural spawn
EntityRegistry.addSpawn(GhoulEntity.class, 100, 4, 4, EnumCreatureType.MONSTER);

// register renderers
proxy.registerRenderers();
        }

Link to post
Share on other sites

Sorry, I forgot to add my method:

@SuppressWarnings("unchecked")
private void registerModEntityWithEgg(@SuppressWarnings("rawtypes") Class entityClass, String entityName, int mobId, int primary, int secondary) {
    EntityRegistry.registerModEntity(entityClass, entityName, mobId, Mobs.instance, 80, 3, false);
    EntityRegistry.registerEgg(entityClass, primary, secondary);
}

 

I'm using the ID generated in the calling method.  I didn't see a method that doesn't take an ID.

Link to post
Share on other sites

First of all, why are you suppressing the rawtypes and unchecked warnings instead of typing your parameters correctly?

You are using the correct method, but the ID it takes doesn't have to be globally unique. FML has a separate set of IDs for every mod, so just start at 0 and increment by 1 for every mob.

Also you do not need to have that helper method at all, there is already a version of registerModEntity in EntityRegistry that takes the spawn-egg colors.

Link to post
Share on other sites

I originally was using a non-global ID, however, that didn't seem to work.

 

Since each mod has it's own ID space, then the code I was using wasn't incorrect, just simply unnecessary, and shouldn't be causing any issues.  I'll update it regardless as it doesn't make sense to keep (both the id selection and the helper method), but it doesn't solve the underlying issue.

Link to post
Share on other sites

Gah, how did I miss this. You are not telling addSpawn any biomes to spawn your mob in, hence it will do exactly nothing.

 

If you want your mob to spawn in all biomes, use something like this:

 

BiomeGenBase[] allBiomes = Arrays.stream(BiomeGenBase.getBiomeGenArray()).filter(Objects::nonNull).toArray(BiomeGenBase[]::new);

Link to post
Share on other sites

Thanks, that did the trick.  The weird thing is I had manually constructed an array with most of all the biomes but that didn't seem to work, so I removed it altogether because I thought if not provided, the default would be all biomes.  Looking at the code - obviously not - doh!  Don't know what I screwed up before, but this works.  Thanks again.

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.   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 Privacy Policy.