Jump to content

[1.11.2] Setting custom mob spawns with Biome Dictionary?


Recommended Posts

I have over 10 mobs I'd like to spawn in various places.

 

I see tags like "Wasteland," "Hot," "Sandy," and "Snowy" among other types I would like to use. And if possible, be able to set up checks to make sure mobs don't spawn in unintended places such as a "Snowy" and "Forest" mob not to spawn in Ice Plains or Roofed Forests for example.

 

Setting spawn frequency would be great too.

Link to comment
Share on other sites

I tried this but it doesn't seem to work:

 

		Set<Biome> biomes;
		Iterator<Biome> biomeIterator;
          
		biomes = BiomeDictionary.getBiomes(Type.SANDY);

		biomeIterator = biomes.iterator();

		while(biomeIterator.hasNext()) 
		{
			Biome currentBiome = biomeIterator.next();
			currentBiome.getSpawnableList(EnumCreatureType.MONSTER).add(new SpawnListEntry(EntityZerglingNincada.class, 590, 3, 6));
			currentBiome.getSpawnableList(EnumCreatureType.MONSTER).add(new SpawnListEntry(EntityRaptorZerglingNincada.class, 555, 3, 5));
			currentBiome.getSpawnableList(EnumCreatureType.MONSTER).add(new SpawnListEntry(EntityCracklingNincada.class, 30, 3, 5));
		}

 

I then tested biomes.isEmpty() and it returned True.

 

Is this the wrong way to approach the Biome set like this?

Link to comment
Share on other sites

It seems that there is a bug in the BiomeDictionary class somehow?

Spoiler

 

I tested it and I also get empty set for any biome type. 

Through the magic of breakpoints I was able to figure that it happens because of the BiomeDictionary::listSupertypes method, specifically the if condition in the while loop (line 392). 

The first statement of the condition is never true as by default the subTypes list is empty for any type but the WATER type.

Thus the supertypes set is always empty, thus the iteration in the addTypes will never happen.

Later down the line it acutally adds the types to the biomeInfo object but that is internal. and is a biome->type mapping, not the reverse. And is private anyway.

In short the BiomeDictionary.Type instance never gets any objects added to it unless there are supertypes registered for it which is never true at <clinit>(the static block which initializes the biome assignment for the first time) for everything but the WATER type.

 

 At least it seems to be this way for me, I might be mistaken as my forge version is not the most recent(I'm 2 versions behind). If I am, I am sorry.

 

For the FuzzyAcornIndustries:

You can iterate through the biome registry and use the BiomeDictionary::getTypes(Biome) method to obtain the types for that specific biome, that should work (works for me). Then you would check if the obtained set contains your desired biome type and add it that way.

Edited by V0idWa1k3r
Link to comment
Share on other sites

27 minutes ago, V0idWa1k3r said:

You can iterate through the biome registry and use the BiomeDictionary::getTypes(Biome) method to obtain the types for that specific biome, that should work (works for me). Then you would check if the obtained set contains your desired biome type and add it that way.

I'm not quite sure how you would do that. Do you perhaps have a text example you could share? It does sound like an attractive way to try over the above one when they have to meet multiple criteria.

 

"::" is not a something I'm familiar with either. What is that?

Link to comment
Share on other sites

:: is simply a way to write method names :)

ClassName::MethodName

As for the code example I suppose it would look something like this:

Multimap<BiomeDictionary.Type, Biome> biomesAndTypes = HashMultimap.create();
for (Biome b : Biome.REGISTRY)
{
    Set<BiomeDictionary.Type> types = BiomeDictionary.getTypes(b);
    for (BiomeDictionary.Type t : types)
    {
        biomesAndTypes.put(t, b);
    }
}
        
EntityRegistry.addSpawn(YourMonsterEntityClass.class, weight, min, max, EnumCreatureType.MONSTER, biomesAndTypes.get(BiomeDictionary.Type.SANDY).toArray(new Biome[biomesAndTypes.get(BiomeDictionary.Type.SANDY).size()]));

 

Or for something more specific(in this case the entity is only allowed to spawn at sandy biomes which are not cold)

List<Biome> criteriaMet = Lists.newArrayList();
for (Biome b : Biome.REGISTRY)
{
    Set<BiomeDictionary.Type> types = BiomeDictionary.getTypes(b);
    if (types.contains(BiomeDictionary.Type.SANDY) && !types.contains(BiomeDictionary.Type.COLD))
    {
        criteriaMet.add(b);
    }
}
        
EntityRegistry.addSpawn(YourMonsterEntityClass.class, weight, min, max, EnumCreatureType.MONSTER, criteriaMet.toArray(new Biome[criteriaMet.size()]));

 

Edited by V0idWa1k3r
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.

Announcements



×
×
  • Create New...

Important Information

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