Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ModWorldGen implements IWorldGenerator {
- @Override
- public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider)
- {
- //Get the dimension, in this case, 0 = Overworld
- if (world.provider.getDimension() == 0) {
- generateOverworld(random, chunkX, chunkZ, world, chunkGenerator, chunkProvider);
- }
- }
- private void generateOverworld(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider)
- {
- //I've commented out one of the ones below to use as example to explain this
- //generateOre(1|ModBlocks.RUBY_ORE.getDefaultState(), 2|world, 3|random, 4|chunkX * 16, 5|chunkZ * 16, 6|4, 7|56, 8|random.nextInt(4) + 1, 9|16);
- // 1| The block-state we want to generate, i.e of the ore we're generating
- // 2| The world we want to generate in (via the World we've passed to this)
- // 3| Random func for generating, rather self-explanatory
- // 4| X position to generate at, 16 cause chunks are 16x16
- // 5| Z position to generate at, once again cause chunks are 16x16
- // 6| Minimum Y height we want for the ore
- // 7| Maximum Y height we want for the ore
- // 8| The size of the vein (continued below)
- // with the +1 being the absolute-minimum the ore can generate at
- // and the part before being how big their max-veins are
- // 9| The number of times attempt-per-chunk to generate (higher values = more likely to spawn)
- //More notes
- //Attempt-per-chunk of 6 to 8 = probably about between rarity of diamond to emerald
- //Attempt-per-chunk of 10 to 12 = around lapis to gold, maybe slightly below gold ore rarity
- //Attempt-per-chunk of 14 to 16 = Around a little bit less than iron but still rarer than gold or so
- // with +16 approaching iron rarity
- //You may need to fiddle with this is you are generating your own ore
- //You can also repurpose this to generate single block non-ore things such as TNT traps, chests, etc, probably by setting random.nextInt to 0
- generateOre(ModBlocks.RUBYORE.getDefaultState(), world, random, chunkX * 16, chunkZ * 16, 4, 56, random.nextInt(4) + 1, 16);
- generateOre(ModBlocks.SAPPHIREORE.getDefaultState(), world, random, chunkX * 16, chunkZ * 16, 4, 56, random.nextInt(4) + 1, 16);
- }
- private void generateOre(IBlockState ore, World world, Random random, int x, int z, int minY, int maxY, int size, int chances)
- {
- int deltaY = maxY - minY;
- for (int i = 0; i < chances; i++) {
- BlockPos pos = new BlockPos(x + random.nextInt(16), minY + random.nextInt(deltaY), z + random.nextInt(16));
- WorldGenMinable generator = new WorldGenMinable(ore, size);
- generator.generate(world, random, pos);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement