Posted February 1, 201510 yr Ok, so as You probably noticed already, learing Forge makes a man bang his head against the wall quite often. To spare You that, I decided do describe what I found. I know one might find the answer through search on this humble forum, but if I had this problem, I'd rather find it in a nice single post detailing that particular situation. And the issue is : "I made a custom mode with a tutorial, and I want it to spawn in custom and moded biomes" Presented solution works for 1.7.10 (yay, no erratas for 1.6.4/1.7.2 upgrades !) : Go to the place in Your code where You register Your mob, like : EntityRegistry.addSpawn(BrigandEntity.class, spawnRate, 2, 4, EnumCreatureType.monster, this.all_biomes); All tutorials I've seen ask You to provide BiomeGenBase.SOMETHING as the last parameter of .addSpawn() , You may however pass an array of BiomeGenBase objects. It is important for this to be an array, not a ArrayList. You need to prepare it before, the solution that I've found to work : ArrayList<BiomeGenBase> all_biomesList = new ArrayList<BiomeGenBase>(); for( BiomeGenBase biome : BiomeGenBase.getBiomeGenArray() ) { if( biome != null ) { all_biomesList.add(biome); // here You may filter biomes which are You like by their properties and insert them in separate ArrayLists } } BiomeGenBase[] all_biomes_array = new BiomeGenBase[all_biomesList.size()]; // type casting from List to array all_biomes = all_biomesList.toArray(all_biomes_array); and "all_biomes" will be Your passable array. Mind You, You may further filter biomes within "if" loop, in order to create more specyfic list of biomes, and than convert it to array as well. TIP: in earlier versions, field BiomeGenBase.biomesList was public, as of 1.7.10 it is not, it can be fetched with BiomeGenBase.getBiomeGenArray(). A living, breathing example (I sure love those in tutorials) : public void register(int banditRate, int brigandRate, int tribesmanRate){ // prepare biomes lists // ArrayList<BiomeGenBase> all_biomesList = new ArrayList<BiomeGenBase>(); ArrayList<BiomeGenBase> cold_biomesList = new ArrayList<BiomeGenBase>(); ArrayList<BiomeGenBase> warmAndMedium_biomesList = new ArrayList<BiomeGenBase>(); for( BiomeGenBase biome : BiomeGenBase.getBiomeGenArray() ) { if( biome != null ) { //all_biomesList.add(biome); if( biome.getIntRainfall()>8000 && biome.getTempCategory()!=TempCategory.OCEAN && biome.heightVariation<0.5F){ // hospitable biomes only if(biome.getTempCategory()==TempCategory.COLD){ // cold biomes cold_biomesList.add(biome); }else{ // medium and warm biomes warmAndMedium_biomesList.add(biome); } } } } //BiomeGenBase[] all_biomes_array = new BiomeGenBase[all_biomesList.size()]; // type casting from List to array and stuff //all_biomes = all_biomesList.toArray(all_biomes_array); BiomeGenBase[] cold_biomes_array = new BiomeGenBase[cold_biomesList.size()]; BiomeGenBase[] warmAndMedium_biomes_array = new BiomeGenBase[warmAndMedium_biomesList.size()]; this.registerBrigand(brigandRate,warmAndMedium_biomesList.toArray(warmAndMedium_biomes_array)); this.registerBandit(banditRate,warmAndMedium_biomesList.toArray(warmAndMedium_biomes_array)); this.registerTribesman(tribesmanRate,cold_biomesList.toArray(cold_biomes_array)); } EDIT: Or... if You may acomplish the same quicker by using BiomeDictionary, like that : // prepare biomes BiomeGenBase[] biomes = new BiomeGenBase[0]; biomes = ArrayUtils.addAll(biomes, BiomeDictionary.getBiomesForType(Type.DENSE)); biomes = ArrayUtils.addAll(biomes, BiomeDictionary.getBiomesForType(Type.FOREST)); biomes = ArrayUtils.addAll(biomes, BiomeDictionary.getBiomesForType(Type.RIVER)); EntityRegistry.addSpawn(BanditEntity.class, spawnRate, 2, 4, EnumCreatureType.monster, biomes);
February 2, 201510 yr Author Yay, approved, so perhaps me be bit smart, ya ? As for the stored array, I don't know much about Java, so it never occured to me that might be wasting memory, lesson learned, thanks Wow, I was not even aware that BiomeDictionary even existed, its kinda awesome. It does make my method kinda pointless by rendering it obsolete though.
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.