Jump to content

1.12 – 1.14 randomly replacing existing biome with custom biome.


salvestrom

Recommended Posts

Ever since I started this mod in 1.7 I have had an optional world type that enabled me to have my jungle biomes spawn within the boundaries of existing jungles. Although it doesn't really affect the mod to not use the world type many people have expressed the desire to have access to the biomes in conjunction with using mods such as biomes o plenty. Recently, I was directed to the mod Buildcraft (1.12) who have their code on github. The link below takes you to the folder where most of the magic occurs. I reproduced this code with only name changes for making sense of it amongst my own mod. 

BuildCraft

I've fiddled with the noise scale and threshold number to increase the biome size and frequency, but the result was not desirable. I think the problem is that the world type event is called after magnification of the biome map so that each passed in coordinate represents a single chunk on the map, instead of a full biome as it does during my current world type code, partially reproduced here:

Spoiler

    public int[] getInts(int areaX, int areaY, int areaWidth, int areaHeight)
    {
        int[] aint = this.parent.getInts(areaX, areaY, areaWidth, areaHeight);
        int[] aint1 = IntCache.getIntCache(areaWidth * areaHeight);

        for (int i = 0; i < areaHeight; ++i)
        {
            for (int j = 0; j < areaWidth; ++j)
            {
                this.initChunkSeed((long)(j + areaX), (long)(i + areaY));
                int k = aint[j + i * areaWidth];
                int l1 = (k & 3840) >> 8;
                k &= -3841;

                if (this.settings != null && this.settings.fixedBiome >= 0)
                {
                    aint1[j + i * areaWidth] = this.settings.fixedBiome;
                }
                else if (isBiomeOceanic(k))
                {
                    aint1[j + i * areaWidth] = k;
                }
                else if (k == Biome.getIdForBiome(Biomes.MUSHROOM_ISLAND))
                {
                    aint1[j + i * areaWidth] = k;
                }
                else if (k == 1)
                {
                    if (l1 > 0)
                    {
                        if (this.nextInt(3) == 0)
                        {
                            aint1[j + i * areaWidth] = Biome.getIdForBiome(Biomes.MESA_CLEAR_ROCK);
                        }
                        else
                        {
                            aint1[j + i * areaWidth] = Biome.getIdForBiome(Biomes.MESA_ROCK);
                        }
                    }
                    else
                    {
                        aint1[j + i * areaWidth] = Biome.getIdForBiome(getWeightedBiomeEntry(BiomeManager.BiomeType.DESERT).biome);
                    }
                }
                else if (k == 2)
                {
                    if (l1 > 0)
                    {
                    	int r = this.nextInt(5);
                    	
                    	if(r == 0) {
                    		
                    		aint1[j + i * areaWidth] = Biome.getIdForBiome(JungleBiomeRegistry.biomeJungleMountain);
                    		
                    		} else
                    			if(r == 4) {
                            		aint1[j + i * areaWidth] = Biome.getIdForBiome(JungleBiomeRegistry.biomeJungleSwamp);
                    			} else {
                    				aint1[j + i * areaWidth] = Biome.getIdForBiome(Biomes.JUNGLE);
                    			}
                    	}
                    else
                    {
                        aint1[j + i * areaWidth] = Biome.getIdForBiome(getWeightedBiomeEntry(BiomeType.WARM).biome);
                    }
                }
                else if (k == 3)
                {
                    if (l1 > 0)
                    {
                        aint1[j + i * areaWidth] = Biome.getIdForBiome(Biomes.REDWOOD_TAIGA);
                    }
                    else
                    {
                        aint1[j + i * areaWidth] = Biome.getIdForBiome(getWeightedBiomeEntry(BiomeType.COOL).biome);
                    }
                }
                else if (k == 4)
                {
                    aint1[j + i * areaWidth] = Biome.getIdForBiome(getWeightedBiomeEntry(BiomeType.ICY).biome);
                }
                else
                {
                    aint1[j + i * areaWidth] = Biome.getIdForBiome(Biomes.MUSHROOM_ISLAND);
                }
            }
        }

        return aint1;
    }

 

I originally cut out the Buildcraft noise generation check in favour of reproducing the jungle section of the JungleGenLayer I had created. This is where I discovered the issue that the random check is applied for every single X, Z coordinate within a chunk leading to a patchwork of biomes one block in size. 

 

Edit: I also wanted to note that using the Buildcraft code doesn't seem to affect the actual terrain/landscape. My mountain biome will be flat and my swamp biome will be hilly. None of the values from my biome classes appear to get applied.

 

1.14
I'm in the middle of updating from 1.12 to 1.14 and thought I would check back to see what had changed with the above. Although the world type event class still exists the hook for it is no longer in the code, so as of now – even if the above were working – I wouldn't be able to use it.

 

The ideal solution would seem to be a hook that occurs before any zooming. Anyone got any other suggestions?

Edited by salvestrom
Missed information
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.