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

How do I generate/ungenerate things in my biome


leonardude
 Share

Recommended Posts

Hey all!

 

I was wondering how do I generate/ungenerate things in my biome. More specifically, I'm looking to disable stone if possible (I know you need your own ChunkProvider to do that but I don't know how to get that to work, it's okay if I can't disable stone), disable the generation of anything (besides stone if it isn't possible to turn off stone generation) vanilla minecraft, including ores, flowers, cacti, trees, etc.. Also, I would want to enable my own flowers, enable my own cactus, enable my own tees etc.

 

This is the code for my biome:

 

package com.leonardude.zether.biomes;

 

import com.leonardude.zether.main.Zether;

 

import net.minecraft.world.biome.BiomeGenBase;

 

public class BiomeGenCorruptDesert extends BiomeGenBase {

 

public BiomeGenCorruptDesert(int id) {

super(id);

 

//Biome Settings

this.setMinMaxHeight(-1.0F, 1.0F);

this.setDisableRain();

this.setTemperatureRainfall(2.0F, 0.0F);

 

//Customize Biome

this.topBlock = (byte) Zether.corrosiveSand.blockID;

this.fillerBlock = (byte) Zether.zetherStone.blockID;

 

//Disable Blocks

 

//Disable Mobs

this.spawnableCaveCreatureList.clear();

this.spawnableCreatureList.clear();

this.spawnableMonsterList.clear();

this.spawnableWaterCreatureList.clear();

 

//Enable Mobs

 

}

 

}

 

PS this biome will be in a custom dimension

 

Thanks in advance!

Leonardude

Link to comment
Share on other sites

In the chunk provider make the change in two of the methods:

 

In generate terrain:

public void generateTerrain(int par1, int par2, byte[] par3ArrayOfByte) {
	byte b0 = 4;
	byte b1 = 16;
	byte b2 = 63;
	int k = b0 + 1;
	byte b3 = 17;
	int l = b0 + 1;
	this.biomesForGeneration = this.worldObj.getWorldChunkManager().getBiomesForGeneration(this.biomesForGeneration, par1 * 4 - 2, par2 * 4 - 2, k + 5, l + 5);
	this.noiseArray = this.initializeNoiseField(this.noiseArray, par1 * b0, 0, par2 * b0, k, b3, l);

	for (int i1 = 0; i1 < b0; ++i1) {
		for (int j1 = 0; j1 < b0; ++j1) {
			for (int k1 = 0; k1 < b1; ++k1) {
				double d0 = 0.125D;
				double d1 = this.noiseArray[((i1 + 0) * l + j1 + 0) * b3 + k1 + 0];
				double d2 = this.noiseArray[((i1 + 0) * l + j1 + 1) * b3 + k1 + 0];
				double d3 = this.noiseArray[((i1 + 1) * l + j1 + 0) * b3 + k1 + 0];
				double d4 = this.noiseArray[((i1 + 1) * l + j1 + 1) * b3 + k1 + 0];
				double d5 = (this.noiseArray[((i1 + 0) * l + j1 + 0) * b3 + k1 + 1] - d1) * d0;
				double d6 = (this.noiseArray[((i1 + 0) * l + j1 + 1) * b3 + k1 + 1] - d2) * d0;
				double d7 = (this.noiseArray[((i1 + 1) * l + j1 + 0) * b3 + k1 + 1] - d3) * d0;
				double d8 = (this.noiseArray[((i1 + 1) * l + j1 + 1) * b3 + k1 + 1] - d4) * d0;

				for (int l1 = 0; l1 < 8; ++l1) {
					double d9 = 0.25D;
					double d10 = d1;
					double d11 = d2;
					double d12 = (d3 - d1) * d9;
					double d13 = (d4 - d2) * d9;

					for (int i2 = 0; i2 < 4; ++i2) {
						int j2 = i2 + i1 * 4 << 11 | 0 + j1 * 4 << 7 | k1 * 8 + l1;
						short short1 = 128;
						j2 -= short1;
						double d14 = 0.25D;
						double d15 = (d11 - d10) * d14;
						double d16 = d10 - d15;

						//requires change in both methods to properly generate custom dimension blocks under biomes
						for (int k2 = 0; k2 < 4; ++k2) {
							if ((d16 += d15) > 0.0D) {
								par3ArrayOfByte[j2 += short1] = (byte) Block.glowStone.blockID;//Block.stone.blockID;
							} else if (k1 * 8 + l1 < b2) {
								par3ArrayOfByte[j2 += short1] = (byte) Fluids.blockRasterWasser.blockID;
							} else {
								par3ArrayOfByte[j2 += short1] = 0;
							}
						}

						d10 += d12;
						d11 += d13;
					}

					d1 += d5;
					d2 += d6;
					d3 += d7;
					d4 += d8;
				}
			}
		}
	}
}

 

And replace block:

public void replaceBlocksForBiome(int par1, int par2, byte[] par3ArrayOfByte, BiomeGenBase[] par4ArrayOfBiomeGenBase) {
	ChunkProviderEvent.ReplaceBiomeBlocks event = new ChunkProviderEvent.ReplaceBiomeBlocks(this, par1, par2, par3ArrayOfByte, par4ArrayOfBiomeGenBase);
	MinecraftForge.EVENT_BUS.post(event);
	if (event.getResult() == Result.DENY)
		return;

	byte b0 = 63;
	double d0 = 0.03125D;
	this.stoneNoise = this.noiseGen4.generateNoiseOctaves(this.stoneNoise, par1 * 16, par2 * 16, 0, 16, 16, 1, d0 * 2.0D, d0 * 2.0D, d0 * 2.0D);

	for (int k = 0; k < 16; ++k) {
		for (int l = 0; l < 16; ++l) {
			BiomeGenBase biomegenbase = par4ArrayOfBiomeGenBase[l + k * 16];
			float f = biomegenbase.getFloatTemperature();
			int i1 = (int) (this.stoneNoise[k + l * 16] / 3.0D + 3.0D + this.rand.nextDouble() * 0.25D);
			int j1 = -1;
			byte b1 = biomegenbase.topBlock;
			byte b2 = biomegenbase.fillerBlock;

			for (int k1 = 127; k1 >= 0; --k1) {
				int l1 = (l * 16 + k) * 128 + k1;

				if (k1 <= 0 + this.rand.nextInt(5)) {
					par3ArrayOfByte[l1] = (byte) Block.bedrock.blockID;
				} else {
					byte b3 = par3ArrayOfByte[l1];

					if (b3 == 0) {
						j1 = -1;
					} else if (b3 == Block.glowStone.blockID) {
						if (j1 == -1) {
							if (i1 <= 0) {
								b1 = 0;
								b2 = (byte) Block.dirt.blockID;//was dirt
							} else if (k1 >= b0 - 4 && k1 <= b0 + 1) {
								b1 = biomegenbase.topBlock;
								b2 = biomegenbase.fillerBlock;
							}

							if (k1 < b0 && b1 == 0) {
								if (f < 0.15F) {
									b1 = (byte) Block.ice.blockID;
								} else {
									b1 = (byte) Fluids.blockRasterWasser.blockID;
								}
							}

							j1 = i1;

							if (k1 >= b0 - 1) {
								par3ArrayOfByte[l1] = b1;
							} else {
								par3ArrayOfByte[l1] = b2;
							}
						} else if (j1 > 0) {
							--j1;
							par3ArrayOfByte[l1] = b2;

							if (j1 == 0 && b2 == Block.sand.blockID) {
								j1 = this.rand.nextInt(4);
								b2 = (byte) Block.sandStone.blockID;
							}
						}
					}
				}
			}
		}
	}
}

 

I made mine create glowstone while I was testing the dimension.

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

 Share



×
×
  • Create New...

Important Information

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