Posted August 6, 20187 yr In my main mod file with my ore generation order, this is what the code looks like. @EventHandler public static void init(FMLInitializationEvent event) { GameRegistry.registerWorldGenerator(new FireOreGen(), 0); GameRegistry.registerWorldGenerator(new WaterOreGen(), 0); } The problem is, only the WaterOreGen works. When i put the FireOreGen line after the WaterOreGen line, only the FireOreGen works. Am I supposed to somehow generate multiple types of ores in one Generator? Or am I doing something wrong in my main mod file? Thanks in advance!
August 6, 20187 yr 1 minute ago, cherrylime said: Am I supposed to somehow generate multiple types of ores in one Generator? You dont have to. But that is what most people do. Use a switch case statement or an if statement. Post your code for the FireOreGen and WaterOreGen classes VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
August 6, 20187 yr Author Here is the FireGen code: package com.cherrylime.minecraftimproved.gen; import java.util.Random; import com.cherrylime.minecraftimproved.blocks.BlockBase; import com.cherrylime.minecraftimproved.init.ModBlocks; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.gen.IChunkGenerator; import net.minecraft.world.gen.feature.WorldGenMinable; import net.minecraft.world.gen.feature.WorldGenerator; import net.minecraftforge.fml.common.IWorldGenerator; public class FireOreGen implements IWorldGenerator { private WorldGenerator fire_ore; public FireOreGen() { fire_ore = new WorldGenMinable(ModBlocks.FIRE_ORE.getDefaultState(), 9); } @Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) { switch(world.provider.getDimension()) { case 0: runGenerator(fire_ore, world, random, chunkX, chunkZ, 10, 0, 50); break; case 1: break; case -1: break; } } private void runGenerator(WorldGenerator gen, World world, Random rand, int chunkX, int chunkZ, int chance, int minHeight, int maxHeight) { if(minHeight > maxHeight || minHeight < 0 || maxHeight > 256) throw new IllegalArgumentException("Ore generated off limits"); int heightDiff = maxHeight - minHeight + 1; for(int i = 0; i < chance; i++) { int x = chunkX * 16 + rand.nextInt(16); int y = minHeight + rand.nextInt(heightDiff); int z = chunkZ * 16 + rand.nextInt(16); gen.generate(world, rand, new BlockPos(x, y, z)); } } } And here is the WaterGen code: package com.cherrylime.minecraftimproved.gen; import java.util.Random; import com.cherrylime.minecraftimproved.blocks.BlockBase; import com.cherrylime.minecraftimproved.init.ModBlocks; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.gen.IChunkGenerator; import net.minecraft.world.gen.feature.WorldGenMinable; import net.minecraft.world.gen.feature.WorldGenerator; import net.minecraftforge.fml.common.IWorldGenerator; public class WaterOreGen implements IWorldGenerator { private WorldGenerator water_ore; public WaterOreGen() { water_ore = new WorldGenMinable(ModBlocks.WATER_ORE.getDefaultState(), 9); } @Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) { switch(world.provider.getDimension()) { case 0: runGenerator(water_ore, world, random, chunkX, chunkZ, 10, 0, 50); break; case 1: break; case -1: break; } } private void runGenerator(WorldGenerator gen, World world, Random rand, int chunkX, int chunkZ, int chance, int minHeight, int maxHeight) { if(minHeight > maxHeight || minHeight < 0 || maxHeight > 256) throw new IllegalArgumentException("Ore generated off limits"); int heightDiff = maxHeight - minHeight + 1; for(int i = 0; i < chance; i++) { int x = chunkX * 16 + rand.nextInt(16); int y = minHeight + rand.nextInt(heightDiff); int z = chunkZ * 16 + rand.nextInt(16); gen.generate(world, rand, new BlockPos(x, y, z)); } } }
August 6, 20187 yr 1 minute ago, cherrylime said: Here is the FireGen code: There is a code block button looks like this <> and a spoiler block button, please use them. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
August 6, 20187 yr Author Quote There is a code block button looks like this <> and a spoiler block button, please use them. Sorry, they aren't showing up in my reply screen, only in my post screen. I'm new to forge forums
August 6, 20187 yr 14 minutes ago, cherrylime said: Sorry, they aren't showing up in my reply screen, only in my post screen. I'm new to forge forums You should switch over to using one WorldGenerator, create two fields in one class and call runGeneration on both. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
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.