Jump to content

Recommended Posts

Posted

Is there anyway to stop the river biome from generating in my custom world type? I have my own GenLayerBiome class, but it's still generating the river.

 

WorldType:

package terrarium.world;

import net.minecraft.world.World;
import net.minecraft.world.WorldType;
import net.minecraft.world.biome.WorldChunkManager;
import net.minecraft.world.gen.layer.GenLayer;
import net.minecraft.world.gen.layer.GenLayerIsland;

public class WorldTypeT extends WorldType {
public int size;

public WorldTypeT(int size) {
	super("SIZE" + size);
	this.size = size;
}

@Override
public WorldChunkManager getChunkManager(World world) {
	return new WorldChunkManagerT(world.getSeed(), this);
}

@Override
public GenLayer getBiomeLayer(long worldSeed, GenLayer parentLayer) {
	return new GenLayerBiomeT(200L, parentLayer, this);
}
}

 

GenLayerBiome:

package terrarium.world;

import net.minecraft.world.WorldType;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.gen.layer.GenLayer;
import net.minecraft.world.gen.layer.GenLayerBiome;
import net.minecraft.world.gen.layer.GenLayerIsland;
import net.minecraft.world.gen.layer.GenLayerSmooth;
import net.minecraft.world.gen.layer.GenLayerVoronoiZoom;
import net.minecraft.world.gen.layer.IntCache;
import terrarium.ServerProxy;
import terrarium.util.MathUtil;

public class GenLayerBiomeT extends GenLayerBiome {
public int size;

public GenLayerBiomeT(long seed, GenLayer layer, WorldTypeT worldType) {
	super(seed, layer, worldType);
	this.size = worldType.size;
}

@Override
public int[] getInts(int chunkX, int chunkZ, int par3, int par4) {
	int[] current = IntCache.getIntCache(par3 * par4);

	int realX;
	int realZ;
	double distance;

	for(int z = 0; z < par4; z++) {
		for(int x = 0; x < par3; x++) {
			realX = x + chunkX;
			realZ = z + chunkZ;

			this.initChunkSeed((long) realX, (long) realZ);

			distance = MathUtil.getDistance2D(0, 0, realX, realZ);

			if(distance > 24 * size) {
				current[x + z * par3] = BiomeGenBase.deepOcean.biomeID;
			} else if(distance > 12 * size) {
				current[x + z * par3] = BiomeGenBase.ocean.biomeID;
			} else if(distance > 9 * size) {
				current[x + z * par3] = BiomeGenBase.taigaHills.biomeID;
			} else if(distance > 6 * size) {
				current[x + z * par3] = BiomeGenBase.desert.biomeID;
			} else if(distance > 3 * size) {
				current[x + z * par3] = BiomeGenBase.forest.biomeID;
			} else {
				current[x + z * par3] = ServerProxy.forest.biomeID;
			}
		}
	}

	return current;
}
}

 

WorldChunkManager:

[code}

package terrarium.world;

 

import java.lang.reflect.Field;

 

import net.minecraft.world.WorldType;

import net.minecraft.world.biome.WorldChunkManager;

import net.minecraft.world.gen.layer.GenLayer;

import terrarium.util.LogUtil;

 

public class WorldChunkManagerT extends WorldChunkManager {

public WorldChunkManagerT(long seed, WorldType worldType) {

super(seed, worldType);

}

}

[/code]

Kain

Posted

I think you star out with the base GenLayer, and then you pass it on to other GenLayers to modify?

 

I tried it earlier, and the 2 GenLayer fields in WorldChunkManager are private.

Kain

Posted

I already have my own chunk manager, it's just that the fields are private. Should I override the methods that use those fields and use my own gen layer?

Kain

Posted

Ok, I got the private field problem out of the way, thanks to reflection <3

 

Current problem is that the world is just a big ocean ATM. I have my own GenLayer in my world type, but it doesn't seem to affect the world.

 

WorldChunkManager:

package terrarium.world;

import java.lang.reflect.Field;

import net.minecraft.world.WorldType;
import net.minecraft.world.biome.WorldChunkManager;
import net.minecraft.world.gen.layer.GenLayerIsland;
import terrarium.util.LogUtil;

public class WorldChunkManagerT extends WorldChunkManager {
public WorldChunkManagerT(long seed, WorldType worldType) {
	super(seed, worldType);

	replaceField("genBiomes", new GenLayerIsland(1000L));
	replaceField("biomeIndexLayer", new GenLayerIsland(1000L));
}

private void replaceField(String fieldName, Object value) {
	Field field = null;

	try {
		field = this.getClass().getSuperclass().getDeclaredField(fieldName);
	} catch(NoSuchFieldException e) {
		e.printStackTrace();
	} catch(SecurityException e) {
		e.printStackTrace();
	}

	if(field != null) {
		LogUtil.info(fieldName + " field found, replacing");

		field.setAccessible(true);

		try {
			field.set(this, new GenLayerIsland(1000L));
		} catch(IllegalArgumentException e) {
			e.printStackTrace();
		} catch(IllegalAccessException e) {
			e.printStackTrace();
		}
	}
}
}

Kain

Posted

I have no clue what I'm doing any more :'(

 

Every is an ocean biome, except for the block at 0, 0, which is a plains biome.

 

WorldChunkManager:

package terrarium.world;

import java.lang.reflect.Field;

import net.minecraft.world.biome.WorldChunkManager;
import net.minecraft.world.gen.layer.GenLayer;
import net.minecraft.world.gen.layer.GenLayerIsland;
import terrarium.util.LogUtil;

public class WorldChunkManagerT extends WorldChunkManager {
public WorldChunkManagerT(long seed, WorldTypeT worldType) {
	super(seed, worldType);

	GenLayer genLayer = GenLayerBiomeT.init(seed, worldType);

	replaceField("genBiomes", genLayer);
	replaceField("biomeIndexLayer", genLayer);
}

private void replaceField(String fieldName, Object value) {
	Field field = null;

	try {
		field = this.getClass().getSuperclass().getDeclaredField(fieldName);
	} catch(NoSuchFieldException e) {
		e.printStackTrace();
	} catch(SecurityException e) {
		e.printStackTrace();
	}

	if(field != null) {
		LogUtil.info(fieldName + " field found, replacing");

		field.setAccessible(true);

		try {
			field.set(this, new GenLayerIsland(1000L));
		} catch(IllegalArgumentException e) {
			e.printStackTrace();
		} catch(IllegalAccessException e) {
			e.printStackTrace();
		}
	}
}
}

 

GenLayerBiomeT:

package terrarium.world;

import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.gen.layer.GenLayer;
import net.minecraft.world.gen.layer.GenLayerBiome;
import net.minecraft.world.gen.layer.GenLayerFuzzyZoom;
import net.minecraft.world.gen.layer.GenLayerSmooth;
import net.minecraft.world.gen.layer.GenLayerVoronoiZoom;
import net.minecraft.world.gen.layer.GenLayerZoom;
import net.minecraft.world.gen.layer.IntCache;
import terrarium.ServerProxy;
import terrarium.util.MathUtil;

public class GenLayerBiomeT extends GenLayerBiome {
public int size;

public GenLayerBiomeT(long seed, WorldTypeT worldType) {
	super(seed, null, worldType);
	this.size = worldType.size;
}

@Override
public int[] getInts(int chunkX, int chunkZ, int par3, int par4) {
	int[] current = IntCache.getIntCache(par3 * par4);

	int realX;
	int realZ;
	double distance;

	for(int z = 0; z < par4; z++) {
		for(int x = 0; x < par3; x++) {
			realX = x + chunkX;
			realZ = z + chunkZ;

			this.initChunkSeed((long) realX, (long) realZ);

			distance = MathUtil.getDistance2D(0, 0, realX, realZ);

			if(distance > 24 * size) {
				current[x + z * par3] = BiomeGenBase.deepOcean.biomeID;
			} else if(distance > 12 * size) {
				current[x + z * par3] = BiomeGenBase.ocean.biomeID;
			} else if(distance > 9 * size) {
				current[x + z * par3] = BiomeGenBase.taigaHills.biomeID;
			} else if(distance > 6 * size) {
				current[x + z * par3] = BiomeGenBase.desert.biomeID;
			} else if(distance > 3 * size) {
				current[x + z * par3] = BiomeGenBase.forest.biomeID;
			} else {
				current[x + z * par3] = ServerProxy.forest.biomeID;
			}
		}
	}

	return current;
}

public static GenLayer init(long seed, WorldTypeT worldType) {
	GenLayer genLayerT = new GenLayerBiomeT(1L, worldType);
	GenLayer genLayerFuzzyZoom1 = new GenLayerFuzzyZoom(2000L, genLayerT);
	GenLayer genLayerFuzzyZoom2 = new GenLayerFuzzyZoom(2001L, genLayerFuzzyZoom1);
	GenLayer genLayerFuzzyZoom3 = new GenLayerFuzzyZoom(2002L, genLayerFuzzyZoom2);
	GenLayer genLayerMagnify = GenLayerZoom.magnify(1000L, genLayerFuzzyZoom3, 0);
	GenLayer genLayerSmooth1 = new GenLayerSmooth(1000L, genLayerMagnify);
	GenLayer genLayerVoronoiZoom = new GenLayerVoronoiZoom(10L, genLayerSmooth1);
	GenLayer genLayerSmooth2 = new GenLayerSmooth(1000L, genLayerVoronoiZoom);

	return genLayerSmooth2;
}
}

Kain

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.