Jump to content

Recommended Posts

Posted

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

Posted

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.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Please read the FAQ and post logs as described there.
    • Upon starting the server I get; [main/ERROR] [minecraft/Main]: Failed to start the minecraft server net.minecraftforge.fml.LoadingFailedException: Loading errors encountered: [     Framework (framework) has failed to load correctly §7java.lang.NoClassDefFoundError: net/minecraft/client/gui/components/toasts/Toast ] I suspect there is a (possibly a few) client-only mods installed on my server. Any help would be appreciated! (Yes I know there are a lot of mods...) Here is the crash log:   https://paste.ee/p/pRz5mhMl#s=0
    • That's basically what the failure does, my apologies for failing to specify.  It just tries again on the next tick until it detects the entities for that chunk are loaded, and then tries to load the entity.  From there it gets into different failure states depending on what goes wrong, but in short, if the entity fails to load once the entity list becomes available, the request is cleared and must be resubmitted by the end user.  There should be few cases where that actually happens. Yes, that is my understanding of forceloading.  That's why on a successful summon, it removes the forceload.  Otherwise it does just leave the chunks loaded long term. Thank you for your help, any knowledge is useful!  I don't often mess with forceloading and my prior experience is 1.16 so I'm also a bit out of my depth haha.
    • I will have to do more research about 1.18 chunk loading. You were unclear about how your code manages with the entity load failure. If you simply used a loop, I suggest submitting a tick task to the next tick which does the same thing, checking if the entities are loaded and if so teleporting the right one else submitting another tick task etc. Also I think forceloading permanently force loads the chunk, and it only starts to unload when you make a subsequent call to mark the chunk as not forceloaded. I may be completely wrong, I dont know much about 1.18, most of my experience is 1.20. Good luck I hope you figure it out after all this time 😅
    • i managed to fix it by reinstalling the modpack and re-add all the extra mods I've had previously.
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

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