Added ore generation

This commit is contained in:
Timo Ley 2021-04-20 09:47:18 +02:00
parent 7e06505e84
commit a819383759
3 changed files with 67 additions and 0 deletions

View file

@ -25,6 +25,16 @@ public class Config {
public static int powerOreRenderID;
public static File engineFile;
public static boolean disableRodSpeed;
public static boolean disableRodHeal;
public static boolean disableRodHeat;
public static boolean disableRodEnder;
public static boolean generateNetherOre = true;
public static boolean generateOre = true;
public static int powerOreFreq = 4;
public static double netherFreq = 1.5;
public static int powerOreRarity = 8;
public static int powerOreSpawnHeight = 48;
private static void generateDefaultEngineFile() {

View file

@ -8,6 +8,7 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import ley.modding.dartcraft.block.DartBlocks;
import ley.modding.dartcraft.entity.*;
@ -19,6 +20,7 @@ import ley.modding.dartcraft.proxy.CommonProxy;
import ley.modding.dartcraft.tab.DartcraftTab;
import ley.modding.dartcraft.util.ForceEngineLiquids;
import ley.modding.dartcraft.util.FortunesUtil;
import ley.modding.dartcraft.worldgen.OreGen;
import ley.modding.tileralib.api.IRegistry;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraftforge.common.MinecraftForge;
@ -55,6 +57,8 @@ public class Dartcraft {
proxy.init();
GameRegistry.registerWorldGenerator(new OreGen(), 2);
int entityId = 0;
EntityRegistry.registerModEntity(EntityColdChicken.class, "coldChicken", entityId++, Dartcraft.instance, 40, 1, true);
EntityRegistry.registerModEntity(EntityColdCow.class, "coldCow", entityId++, Dartcraft.instance, 40, 1, true);

View file

@ -0,0 +1,53 @@
package ley.modding.dartcraft.worldgen;
import cpw.mods.fml.common.IWorldGenerator;
import ley.modding.dartcraft.Config;
import ley.modding.dartcraft.block.DartBlocks;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenMinable;
import java.util.Random;
public class OreGen implements IWorldGenerator {
WorldGenMinable powerMinable = new WorldGenMinable(DartBlocks.powerore, Config.powerOreFreq);
WorldGenMinable netherMinable = new WorldGenMinable(DartBlocks.powerore, 1, Config.powerOreFreq, Blocks.netherrack);
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
doGeneration(random, chunkX, chunkZ, world);
}
public void doGeneration(Random rand, int chunkX, int chunkZ, World world) {
if (world.provider.dimensionId == -1 && Config.generateNetherOre) {
generateNether(rand, chunkX, chunkZ, world);
return;
}
if (world.provider.dimensionId == 1)
return;
if (Config.generateOre)
normalGen(rand, chunkX, chunkZ, world);
}
public void generateNether(Random rand, int chunkX, int chunkZ, World world) {
for (int i = 0; i < (int)(Config.powerOreRarity * Config.netherFreq); i++) {
int posx = chunkX * 16 + rand.nextInt(16);
int posy = rand.nextInt(128);
int posz = chunkZ * 16 + rand.nextInt(16);
this.netherMinable.generate(world, rand, posx, posy, posz);
}
}
public void normalGen(Random rand, int chunkX, int chunkZ, World world) {
for (int i = 0; i < Config.powerOreRarity; i++) {
int posx = chunkX * 16 + rand.nextInt(16);
int posy = rand.nextInt(Config.powerOreSpawnHeight);
int posz = chunkZ * 16 + rand.nextInt(16);
this.powerMinable.generate(world, rand, posx, posy, posz);
}
}
}