Jump to content

[1.16.4] Editing BiomeContainer with Custom Biome generates Error: "Received invalid biome id: -1"


killerjdog51

Recommended Posts

So I have an Oasis feature that generates and edits the biome around it. The feature generation part works well, the issue is that it no longer edits the biome like it did in previous versions (1.12, 1.14, & 1.15). Or it does, but instead of my custom biome it generates the "Received invalid biome id: -1" error and uses the Minecraft:Ocean biome. The biome spawns perfectly fine if I generate it using the single biome world type. 

OasisBiome

 

Link to comment
Share on other sites

I've narrowed things down to:

	public int getInt(final Object k) {
		if ((strategy.equals(((K) k), (null))))
			return containsNullKey ? value[n] : defRetValue;
		K curr;
		final K[] key = this.key;
		int pos;
		// The starting point.
		if (((curr = key[pos = (it.unimi.dsi.fastutil.HashCommon.mix(strategy.hashCode((K) k))) & mask]) == null))
			return defRetValue;
		if ((strategy.equals((K) (k), (curr))))
			return value[pos];
		// There's always an unused entry.
		while (true) {
			if (((curr = key[pos = (pos + 1) & mask]) == null))
				return defRetValue;
			if ((strategy.equals((K) (k), (curr))))
				return value[pos];
		}
	}

 

Somehow the key[pos = (it.unimi.dsi.fastutil.HashCommon.mix(strategy.hashCode((K) k))) & mask] is used to calculate the biome data position within the list K. For some reason it seems like my inserted biome returns the wrong position value (though it is within the K list). I've tested it with Minecraft biomes like forest and mushroom fields, they also don't return the correct position unless its natural generation (not inserted like mine). 

Does anyone have ideas on why this is? If I had to guess inserting the biome data generates a different hash, but I don't understand why. perhaps its caused by ForgeRegistries.BIOMES.getValue()?

Link to comment
Share on other sites

On 7/4/2021 at 1:12 PM, diesieben07 said:

Biomes are loaded dynamically from datapacks. As far as I know you have to use World#registryAccess to get the DynamicRegistries and then use those to look up the biome (don't quote me on this). Alternatively you can just check the RegistryKey without converting to Biome.

Thanks, it worked! I'm an idiot for not realizing that biomes were dynamic and being called within the BiomeContainer with its own version of a dynamic Biome Registry. All I had to do was grab copy the reference to that and get a reference to my biome and the dynamic biome id that way. 

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.