Posted December 28, 201311 yr So this is my world gen everything seems to look fine but it doenst work it generates altars trees and such but it only generates them in deserts. When it does generates it generates around 10 trees perchuck and i can't seem to find out what i'm doing wrong help please import java.util.Random; import net.minecraft.world.World; import net.minecraft.world.chunk.IChunkProvider; import cpw.mods.fml.common.IWorldGenerator; import cpw.mods.fml.common.registry.GameRegistry; public class WorldGeneratorTrees implements IWorldGenerator { public WorldGeneratorTrees() { GameRegistry.registerWorldGenerator(this); } @SuppressWarnings("static-access") @Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { if(!(world.getWorldInfo().getTerrainType() == world.getWorldInfo().getTerrainType().FLAT)){ generateBigTree(world, random, chunkX, chunkZ); generateAltar(world, random, chunkX, chunkZ); generateOtherTree(world, random, chunkX, chunkZ); for(int i = 0; i < 1; i++){ int x = chunkX + random.nextInt(32); int z = chunkZ + random.nextInt(32); int y = world.getHeightValue(x, z); new WorldGenTeak().generate(world, random, x, y, z); } for(int i = 0; i < 1; i++){ int x = chunkX + random.nextInt(32); int z = chunkZ + random.nextInt(32); int y = world.getHeightValue(x, z); new WorldGenHollow().generate(world, random, x, y, z); } for(int i = 0; i < 1; i++){ int x = chunkX + random.nextInt(32); int z = chunkZ + random.nextInt(32); int y = world.getHeightValue(x, z); new WorldGenWillow().generate(world, random, x, y, z); } } } public static void generateAltar(World world, Random random, int chunkX, int chunkZ) { for(int i = 0; i < 1; i++){ int x = chunkX + random.nextInt(32); int z = chunkZ + random.nextInt(32); int y = world.getHeightValue(x, z); new EssenceMine().generate(world, random, x, y, z); } for(int i = 0; i < 1; i++){ int x = chunkX + random.nextInt(128); int z = chunkZ + random.nextInt(128); int y = world.getHeightValue(x, z); new WorldGenAltarAir().generate(world, random, x, y, z); } } public static void generateOtherTree(World world, Random random, int chunkX, int chunkZ) { for(int i = 0; i < 1; i++){ int x = chunkX + random.nextInt(32); int z = chunkZ + random.nextInt(32); int y = world.getHeightValue(x, z); new WorldGenTeak().generate(world, random, x, y, z); } for(int i = 0; i < 1; i++){ int x = chunkX + random.nextInt(32); int z = chunkZ + random.nextInt(32); int y = world.getHeightValue(x, z); new WorldGenHollow().generate(world, random, x, y, z); } for(int i = 0; i < 1; i++){ int x = chunkX + random.nextInt(32); int z = chunkZ + random.nextInt(32); int y = world.getHeightValue(x, z); new WorldGenWillow().generate(world, random, x, y, z); } } public static void generateBigTree(World world, Random random, int chunkX, int chunkZ) { //normaal for(int i = 0; i < 1; i++){ int x = chunkX + random.nextInt(128); int z = chunkZ + random.nextInt(128); int y = world.getHeightValue(x, z); new WorldGenTree(false, 5, 0, 0, false, WoodCutting.woodcuttingleaves.blockID, WoodCutting.woodcuttinglog.blockID).generate(world, random, x, y, z); } //oak for(int i = 0; i < 1; i++){ int x = chunkX + random.nextInt(64); int z = chunkZ + random.nextInt(64); int y = world.getHeightValue(x, z); int meta = 2; new WorldGenBigTree(true, WoodCutting.woodcuttinglog.blockID, meta, WoodCutting.woodcuttingleaves.blockID, meta).generate(world, random, x, y, z); } //yew for(int i = 0; i < 1; i++){ int x = chunkX + random.nextInt(128); int z = chunkZ + random.nextInt(128); int y = world.getHeightValue(x, z); int meta = 9; new WorldGenBigTree(true, WoodCutting.woodcuttinglog.blockID, meta, WoodCutting.woodcuttingleaves.blockID, meta).generate(world, random, x, y, z); } //mahogany for(int i = 0; i < 1; i++){ int x = chunkX + random.nextInt(32); int z = chunkZ + random.nextInt(32); int y = world.getHeightValue(x, z); int meta = 7; new WorldGenBigTree(true, WoodCutting.woodcuttinglog.blockID, meta, WoodCutting.woodcuttingleaves.blockID, meta).generate(world, random, x, y, z); } //maple for(int i = 0; i < 1; i++){ int x = chunkX + random.nextInt(32); int z = chunkZ + random.nextInt(32); int y = world.getHeightValue(x, z); int meta = 5; new WorldGenBigTree(true, WoodCutting.woodcuttinglog.blockID, meta, WoodCutting.woodcuttingleaves.blockID, meta).generate(world, random, x, y, z); } } } I'm always happy to help others! Java is not my main programming language but I have alot experience in PHP/HTML/JS/CSS3/C#/SQL
December 28, 201311 yr Not sure about your desert problem. Maybe the problem is in one of the other World Gen files. When you use .nextInt though Im pretty sure you want the upper limit to always be 16 so it only spawns into that chunk.
December 28, 201311 yr When you use .nextInt though Im pretty sure you want the upper limit to always be 16 so it only spawns into that chunk. Just to clarify this portion. He's talking about these lines: int x = chunkX + random.nextInt(32); int z = chunkZ + random.nextInt(32); You shouldn't generate a value higher than 15 with your random, or you're not generating inside that chunk, you're generating in a neighboring chunk. And while you can, you shouldn't. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
December 28, 201311 yr chunkX and chunkZ are the chunk coordinates, not world coordinates, by the way.
December 28, 201311 yr To fix the desert problem we need to see the other files still. It might be something simple like using sand as the valid block to spawn the trees on.
December 28, 201311 yr Author Okay well thanks i'll change all the values to 16 to test it again hold on I'm always happy to help others! Java is not my main programming language but I have alot experience in PHP/HTML/JS/CSS3/C#/SQL
December 28, 201311 yr Author Nothing seems to generate now. public WorldGeneratorTrees() { GameRegistry.registerWorldGenerator(this); } @SuppressWarnings("static-access") @Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { if(!(world.getWorldInfo().getTerrainType() == world.getWorldInfo().getTerrainType().FLAT)){ generateBigTree(world, random, chunkX, chunkZ); generateAltar(world, random, chunkX, chunkZ); generateOtherTree(world, random, chunkX, chunkZ); for(int i = 0; i < 15; i++){ int x = chunkX + random.nextInt(16); int z = chunkZ + random.nextInt(16); int y = world.getHeightValue(x, z); new WorldGenTeak().generate(world, random, x, y, z); } for(int i = 0; i < 15; i++){ int x = chunkX + random.nextInt(16); int z = chunkZ + random.nextInt(16); int y = world.getHeightValue(x, z); new WorldGenHollow().generate(world, random, x, y, z); } for(int i = 0; i < 15; i++){ int x = chunkX + random.nextInt(16); int z = chunkZ + random.nextInt(16); int y = world.getHeightValue(x, z); new WorldGenWillow().generate(world, random, x, y, z); } } } public static void generateAltar(World world, Random random, int chunkX, int chunkZ) { for(int i = 0; i < 1; i++){ int x = chunkX + random.nextInt(16); int z = chunkZ + random.nextInt(16); int y = world.getHeightValue(x, z); new EssenceMine().generate(world, random, x, y, z); } for(int i = 0; i < 1; i++){ int x = chunkX + random.nextInt(16); int z = chunkZ + random.nextInt(16); int y = world.getHeightValue(x, z); new WorldGenAltarAir().generate(world, random, x, y, z); } } public static void generateOtherTree(World world, Random random, int chunkX, int chunkZ) { for(int i = 0; i < 1; i++){ int x = chunkX + random.nextInt(16); int z = chunkZ + random.nextInt(16); int y = world.getHeightValue(x, z); new WorldGenTeak().generate(world, random, x, y, z); } for(int i = 0; i < 1; i++){ int x = chunkX + random.nextInt(16); int z = chunkZ + random.nextInt(16); int y = world.getHeightValue(x, z); new WorldGenHollow().generate(world, random, x, y, z); } for(int i = 0; i < 1; i++){ int x = chunkX + random.nextInt(16); int z = chunkZ + random.nextInt(16); int y = world.getHeightValue(x, z); new WorldGenWillow().generate(world, random, x, y, z); } } public static void generateBigTree(World world, Random random, int chunkX, int chunkZ) { //normaal for(int i = 0; i < 1; i++){ int x = chunkX + random.nextInt(16); int z = chunkZ + random.nextInt(16); int y = world.getHeightValue(x, z); new WorldGenTree(false, 5, 0, 0, false, WoodCutting.woodcuttingleaves.blockID, WoodCutting.woodcuttinglog.blockID).generate(world, random, x, y, z); } //oak for(int i = 0; i < 1; i++){ int x = chunkX + random.nextInt(16); int z = chunkZ + random.nextInt(16); int y = world.getHeightValue(x, z); int meta = 2; new WorldGenBigTree(true, WoodCutting.woodcuttinglog.blockID, meta, WoodCutting.woodcuttingleaves.blockID, meta).generate(world, random, x, y, z); } //yew for(int i = 0; i < 1; i++){ int x = chunkX + random.nextInt(16); int z = chunkZ + random.nextInt(16); int y = world.getHeightValue(x, z); int meta = 9; new WorldGenBigTree(true, WoodCutting.woodcuttinglog.blockID, meta, WoodCutting.woodcuttingleaves.blockID, meta).generate(world, random, x, y, z); } //mahogany for(int i = 0; i < 1; i++){ int x = chunkX + random.nextInt(16); int z = chunkZ + random.nextInt(16); int y = world.getHeightValue(x, z); int meta = 7; new WorldGenBigTree(true, WoodCutting.woodcuttinglog.blockID, meta, WoodCutting.woodcuttingleaves.blockID, meta).generate(world, random, x, y, z); } //maple for(int i = 0; i < 1; i++){ int x = chunkX + random.nextInt(16); int z = chunkZ + random.nextInt(16); int y = world.getHeightValue(x, z); int meta = 5; new WorldGenBigTree(true, WoodCutting.woodcuttinglog.blockID, meta, WoodCutting.woodcuttingleaves.blockID, meta).generate(world, random, x, y, z); } } } on the models so they should spawn normally protected int[] GetValidSpawnBlocks() { return new int[] { Block.grass.blockID, Block.dirt.blockID }; } I'm always happy to help others! Java is not my main programming language but I have alot experience in PHP/HTML/JS/CSS3/C#/SQL
December 28, 201311 yr You need to multiply chunkX and chunkZ by 16, as they are chunk coordinates, not world coordinates. int x = chunkX*16 + random.nextInt(16); Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
December 28, 201311 yr Author I thank you sir ^^ I'm always happy to help others! Java is not my main programming language but I have alot experience in PHP/HTML/JS/CSS3/C#/SQL
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.