use of net.silentchaos512.gems.world.GemsWorldGenerator in project SilentGems by SilentChaos512.
the class GemsWorldGenerator method selectState.
/**
* Selects an IBlockState for the config. For gems, it will normally choose one randomly each call. For essence ores,
* it selects the appropriate ore.
*
* @param config
* @param random
* @return
*/
protected IBlockState selectState(ConfigOptionOreGen config, Random random, World world, int posX, int posZ) {
if (config == GemsConfig.WORLD_GEN_GEMS) {
EnumGem gem;
if (GemsConfig.GEM_REGIONS_ENABLED) {
// Gem Regions
long dimension = (long) world.provider.getDimension();
long cx = (long) posX / 16 / GemsConfig.GEM_REGIONS_SIZE;
long cz = (long) posZ / 16 / GemsConfig.GEM_REGIONS_SIZE;
long seed = (world.getSeed() << 40L) | ((dimension & 0xFF) << 32L) | ((cz & 0xFFFF) << 16L) | (cx & 0xFFFF);
Random regionRandom = new Random(seed);
EnumGem firstGem = EnumGem.values()[regionRandom.nextInt(16)];
EnumGem secondGem = EnumGem.values()[regionRandom.nextInt(16)];
if (regionRandom.nextFloat() < GemsConfig.GEM_REGIONS_SECOND_GEM_CHANCE && random.nextBoolean()) {
gem = secondGem;
} else {
gem = firstGem;
}
} else {
// Classic logic
int meta = ((WeightedRandomItemSG) WeightedRandom.getRandomItem(random, GemsConfig.GEM_WEIGHTS)).getMeta();
gem = EnumGem.values()[meta];
}
return ModBlocks.gemOre.getDefaultState().withProperty(EnumGem.VARIANT_GEM, gem);
} else if (config == GemsConfig.WORLD_GEN_CHAOS) {
return ModBlocks.essenceOre.getDefaultState().withProperty(BlockEssenceOre.VARIANT, BlockEssenceOre.Type.CHAOS);
} else if (config == GemsConfig.WORLD_GEN_GEMS_DARK) {
int meta = ((WeightedRandomItemSG) WeightedRandom.getRandomItem(random, GemsConfig.GEM_WEIGHTS_DARK)).getMeta();
EnumGem gem = EnumGem.values()[meta];
return ModBlocks.gemOreDark.getDefaultState().withProperty(EnumGem.VARIANT_GEM, gem);
} else if (config == GemsConfig.WORLD_GEN_ENDER) {
return ModBlocks.essenceOre.getDefaultState().withProperty(BlockEssenceOre.VARIANT, BlockEssenceOre.Type.ENDER);
} else if (config == GemsConfig.WORLD_GEN_GEMS_LIGHT) {
int meta = ((WeightedRandomItemSG) WeightedRandom.getRandomItem(random, GemsConfig.GEM_WEIGHTS_LIGHT)).getMeta();
EnumGem gem = EnumGem.values()[meta];
return ModBlocks.gemOreLight.getDefaultState().withProperty(EnumGem.VARIANT_GEM, gem);
} else {
SilentGems.logHelper.severe("GemsWorldGenerator - Unknown ore config: " + config.name);
return null;
}
}
use of net.silentchaos512.gems.world.GemsWorldGenerator in project SilentGems by SilentChaos512.
the class SilentGems method preInit.
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
localizationHelper = new LocalizationHelper(MODID).setReplaceAmpersand(true);
SilentLib.instance.registerLocalizationHelperForMod(MODID, localizationHelper);
CommonItemStats.init();
ToolHelper.init();
GemsConfig.INSTANCE.init(event.getSuggestedConfigurationFile());
registry.addRegistrationHandler(new ModEnchantments(), Enchantment.class);
registry.addRegistrationHandler(new ModBlocks(), Block.class);
registry.addRegistrationHandler(new ModItems(), Item.class);
registry.addRegistrationHandler(new ModPotions(), Potion.class);
registry.addRegistrationHandler(new ModRecipes(), IRecipe.class);
ModParts.init();
SoulSkill.init();
GemsConfig.INSTANCE.loadModuleConfigs();
// TODO: Achievements
// World generation
GameRegistry.registerWorldGenerator(new GemsWorldGenerator(), 0);
GameRegistry.registerWorldGenerator(new GemsGeodeWorldGenerator(), -10);
// Headcrumbs
FMLInterModComms.sendMessage("headcrumbs", "add-username", Names.SILENT_CHAOS_512);
// Load TCon compatibility stuff?
if (Loader.isModLoaded("tconstruct")) {
TConstructGemsCompat.preInit();
}
VeinMinerCompat.init();
proxy.preInit(registry);
}
Aggregations