Posted November 28, 20159 yr For some reason I am unable to generate custom ore/blocks in Savannah biomes. All other biomes I have tried no problems. I am trying to generate the "Block_3" on the surface of the Savannah. I recall reading somewhere that you can only replace certain blocks? The surface of Savannah is usually stone is there a way to change this code to replace the grass or stone on the surface of the Savannah? package com.glistre.glistremod.biome; import com.glistre.glistremod.BlockRegistry; import java.util.Random; import net.minecraft.init.Blocks; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.gen.feature.WorldGenMinable; import net.minecraft.world.gen.feature.WorldGenerator; import cpw.mods.fml.common.IWorldGenerator; public class BlockGenGlistre implements IWorldGenerator { @Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { switch(world.provider.dimensionId) { //case 0 = Overworld case 0: generateSurface(world, random, chunkX*16,chunkZ*16); } } private void generateSurface(World world, Random random, int chunkX, int chunkZ) { BiomeGenBase b = world.getBiomeGenForCoords(chunkX, chunkZ); if (b.biomeName.equals("Savannah")) for(int i =0; i<10; i++){ int Xcoord = chunkX + random.nextInt(16); int Zcoord = chunkZ + random.nextInt(16); // int Ycoord = random.nextInt(256); int Ycoord = world.getHeightValue(Xcoord, Zcoord); (new WorldGenMinable(BlockRegistry.Block_3, 22)).generate(world, random, Xcoord, Ycoord, Zcoord); //this below just tells me if its generating or not System.out.println("Generating Glistre Blocks in Savannah"); } else if (b.biomeName.equals("Savannah Plateau")) for(int i =0; i<10; i++){ int Xcoord = chunkX + random.nextInt(16); int Zcoord = chunkZ + random.nextInt(16); // int Ycoord = random.nextInt(256); int Ycoord = world.getHeightValue(Xcoord, Zcoord); (new WorldGenMinable(BlockRegistry.Block_3, 22)).generate(world, random, Xcoord, Ycoord, Zcoord); //this below just tells me if its generating or not System.out.println("Generating Glistre Blocks in Savannah Plateau"); } else if (b.biomeName.equals("Birch Forest")) for(int i =0; i<100; i++){ int Xcoord = chunkX + random.nextInt(16); int Zcoord = chunkZ + random.nextInt(16); // int Ycoord = random.nextInt(256); int Ycoord = world.getHeightValue(Xcoord, Zcoord); (new WorldGenMinable(BlockRegistry.Block_2, 22)).generate(world, random, Xcoord, Ycoord, Zcoord); //this below just tells me if its generating or not System.out.println("Generating Silver Blocks in Birch Forest"); } else if (b.biomeName.equals("Extreme Hills")) for(int i =0; i<10; i++){ int Xcoord = chunkX + random.nextInt(16); int Zcoord = chunkZ + random.nextInt(16); int Ycoord = random.nextInt(256); // int Ycoord = world.getHeightValue(Xcoord, Zcoord); (new WorldGenMinable(BlockRegistry.Block_1, 20)).generate(world, random, Xcoord, Ycoord, Zcoord); //this below just tells me if its generating or not System.out.println("Generating Silver Ore in Extreme Hills"); } } }
November 28, 20159 yr See, it helps if you actually look at the BiomeGenBase class. public static final BiomeGenBase savanna = (new BiomeGenSavanna(35)).setColor(12431967).setBiomeName("Savanna").setTemperatureRainfall(1.2F, 0.0F).setDisableRain().setHeight(height_LowPlains); public static final BiomeGenBase savannaPlateau = (new BiomeGenSavanna(36)).setColor(10984804).setBiomeName("Savanna Plateau").setTemperatureRainfall(1.0F, 0.0F).setDisableRain().setHeight(height_HighPlateaus); "Savanna" will never equal "Savannah" Second, there's a public static reference right there you can compare to without having to do string comparison (which is expensive). Third, it is possible for the savanna biome to show up in dimensions other than the overworld, e.g. Mystcraft ages. You should let your ore generate in all dimensions as long as the biome check is valid. 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.
November 28, 20159 yr Author I am flocking blind thank you for the suggestions and the eyes I will change it I was noticing a bit of "warning: clientsidechunkingticking took ..." error and lag hope that gets rid of it
November 28, 20159 yr Author See, it helps if you actually look at the BiomeGenBase class. public static final BiomeGenBase savanna = (new BiomeGenSavanna(35)).setColor(12431967).setBiomeName("Savanna").setTemperatureRainfall(1.2F, 0.0F).setDisableRain().setHeight(height_LowPlains); public static final BiomeGenBase savannaPlateau = (new BiomeGenSavanna(36)).setColor(10984804).setBiomeName("Savanna Plateau").setTemperatureRainfall(1.0F, 0.0F).setDisableRain().setHeight(height_HighPlateaus); "Savanna" will never equal "Savannah" Second, there's a public static reference right there you can compare to without having to do string comparison (which is expensive). Third, it is possible for the savanna biome to show up in dimensions other than the overworld, e.g. Mystcraft ages. You should let your ore generate in all dimensions as long as the biome check is valid. Not real sure if I am doing this right it seems to work. ...am I doing the Height part and any of this correct? It works but I would appreciate your input if you have a sec to look at it package com.glistre.glistremod.blocks; import java.util.Random; import com.glistre.glistremod.blocks.BlockRegistry; import net.minecraft.init.Blocks; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.biome.BiomeGenSavanna; import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.gen.feature.WorldGenMinable; import net.minecraft.world.gen.feature.WorldGenerator; import cpw.mods.fml.common.IWorldGenerator; public class BlockGenSavanna implements IWorldGenerator { @Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { switch(world.provider.dimensionId) { //case 0 = Overworld case 0: generateSurface(world, random, chunkX*16,chunkZ*16); break; //case 0 = Nether case -1: generateSurface(world, random, chunkX*16,chunkZ*16); break; //case 0 = End case 1: generateSurface(world, random, chunkX*16,chunkZ*16); break; } } BiomeGenBase.Height height_LowPlains = new BiomeGenBase.Height(0.125F, 0.05F); BiomeGenBase.Height height_HighPlateaus = new BiomeGenBase.Height(1.5F, 0.025F); private void generateSurface(World world, Random random, int chunkX, int chunkZ) { BiomeGenBase savanna = new BiomeGenSavanna(35).setColor(12431967).setBiomeName("Savanna").setTemperatureRainfall(1.2F, 0.0F).setDisableRain(); BiomeGenBase savannaPlateau = new BiomeGenSavanna(36).setColor(10984804).setBiomeName("Savanna Plateau").setTemperatureRainfall(1.0F, 0.0F).setDisableRain(); BiomeGenBase b = world.getBiomeGenForCoords(chunkX, chunkZ); if (b == savanna) for(int i =0; i<20; i++){ int Xcoord = chunkX + random.nextInt(16); int Zcoord = chunkZ + random.nextInt(16); // int Ycoord = random.nextInt(256); int Ycoord = world.getHeightValue(Xcoord, Zcoord); (new WorldGenMinable(BlockRegistry.MyBlock_3, 22)).generate(world, random, Xcoord, Ycoord, Zcoord); //this below just tells me if its generating or not System.out.println("Generating Glistre Blocks in Savanna"); } else if (b == savannaPlateau) for(int i =0; i<10; i++){ int Xcoord = chunkX + random.nextInt(16); int Zcoord = chunkZ + random.nextInt(16); // int Ycoord = random.nextInt(256); int Ycoord = world.getHeightValue(Xcoord, Zcoord); (new WorldGenMinable(BlockRegistry.MyBlock_3, 22)).generate(world, random, Xcoord, Ycoord, Zcoord); //this below just tells me if its generating or not System.out.println("Generating Glistre Blocks in Savanna Plateau"); } } }
November 28, 20159 yr Why are you creating new instances of BiomeGenBase ? Use the static instance in BiomeGenBase.class . Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
November 28, 20159 yr Followed by: switch(world.provider.dimensionId) { //case 0 = Overworld case 0: generateSurface(world, random, chunkX*16,chunkZ*16); break; //case 0 = Nether case -1: generateSurface(world, random, chunkX*16,chunkZ*16); break; //case 0 = End case 1: generateSurface(world, random, chunkX*16,chunkZ*16); break; } } What happens when dimension 47 generates and is an overworld clone? The reason I mentioned the other dimensions was not so you would run your code on the nether and the end (which, by the way, is pointless as the savanna never shows up in either of those) but so that you would add a default case so that it could handle ANY mod-added dimension. 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.
November 28, 20159 yr Author Why are you creating new instances of BiomeGenBase ? Use the static instance in BiomeGenBase.class . Because I'm a dumbass I changed it to this : package com.glistre.glistremod.blocks; import java.util.Random; import com.glistre.glistremod.blocks.BlockRegistry; import net.minecraft.init.Blocks; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.biome.BiomeGenSavanna; import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.gen.feature.WorldGenMinable; import net.minecraft.world.gen.feature.WorldGenerator; import cpw.mods.fml.common.IWorldGenerator; public class BlockGenSavanna implements IWorldGenerator { @Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { switch(world.provider.dimensionId) { //case 0 = Overworld case 0: generateSurface(world, random, chunkX*16,chunkZ*16); break; //case -1 = Nether case -1: generateSurface(world, random, chunkX*16,chunkZ*16); break; //case 1 = End case 1: generateSurface(world, random, chunkX*16,chunkZ*16); break; } } private void generateSurface(World world, Random random, int chunkX, int chunkZ) { BiomeGenBase b = world.getBiomeGenForCoords(chunkX, chunkZ); if (b == BiomeGenBase.savanna || b == BiomeGenBase.savannaPlateau) for(int i =0; i<20; i++){ int Xcoord = chunkX + random.nextInt(16); int Zcoord = chunkZ + random.nextInt(16); // int Ycoord = random.nextInt(256); int Ycoord = world.getHeightValue(Xcoord, Zcoord); (new WorldGenMinable(BlockRegistry.MyBlock_3, 22)).generate(world, random, Xcoord, Ycoord, Zcoord); //this below just tells me if its generating or not System.out.println("Generating Glistre Blocks in Savanna and Savanna Plateau"); } } }
November 29, 20159 yr That should work, but it still won't generate in a Mystcraft dimension. 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.
November 29, 20159 yr Author That should work, but it still won't generate in a Mystcraft dimension. So maybe add something like case Glistreland.DIMENSIONID ... make a custom dimension?
November 29, 20159 yr No. You know how a switch statement works? You can add a default which is the default thing to do if the other cases don't hit. So instead of case #: , you do default: . That way, as Draco18s said three times before, it will generate in every dimension with a Savanna biome, instead of only the Overworld. Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
November 29, 20159 yr Author No. You know how a switch statement works? You can add a default which is the default thing to do if the other cases don't hit. So instead of case #: , you do default: . That way, as Draco18s said three times before, it will generate in every dimension with a Savanna biome, instead of only the Overworld. Would this work for Mystcraft etc? @Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { switch(world.provider.dimensionId) { //case -1 = Nether case -1: generateSurface(world, random, chunkX*16,chunkZ*16); break; //case 0 = Overworld case 0: generateSurface(world, random, chunkX*16,chunkZ*16); break; //case 1 = End case 1: generateSurface(world, random, chunkX*16,chunkZ*16); break; //default case e.g. Mystcraft ..others default: generateSurface(world, random, chunkX*16,chunkZ*16); break; } }
November 29, 20159 yr Yes, it would, though it is a bit redundant if the 3 cases and the default all do the same thing. Unless you are going to change the Nether and the End case to something else, you might aswell remove the switch statement. Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
November 30, 20159 yr Perfect. I spoke up about it as I know that other mods did something similar as you had done, checking "is overworld" rather than "is not nether, end" 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.
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.