Jump to content

Recommended Posts

Posted (edited)

So I have a generator that spawn structures in the world. It will only spawn structures in the designated Biomes. So for example, certain trees will only spawn in my BiomeMysticLands.class.

I created another structure that I want to have spawn everywhere, in all Biomes. Storing them in an array is what I'm guessing is the best course of action, but the problem is fetching them all to put in the array.

I mean sure I can manually create an array and do Biome.BEACH.getClass(), Biome.FOREST.getClass, etc. etc. But there has to be a more efficeint way right?

 

Here is the Code: https://pastebin.com/4H5QYEic

 

This is a tutorial that I happend to find heavily modified for some nice structure generation.

 

Now if it is not feasable or efficient to fetch the Biome classes then technically, i could do/add an or classesList.isEmpty()  check when the code reachs the classesList.contains(biome) right? Which would mean since you didn't put anything in the Vararg segment it would pass the check?

Edited by HalestormXV
Posted

Because now there is the event-based biome registration you can use ForgeRegistries.BIOMES.getValues() to get all the biomes.


I believe this method would give all the biomes available in the game across all world types. To determine if a biome is for the nether or end, you can use the BiomeDictionary and use the getTypes() method to check if the biome is of Type.NETHER or Type.END. You could similarly use the dictionary to rule out any other categories of biome appropriate to your need.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted
10 hours ago, jabelar said:

Because now there is the event-based biome registration you can use ForgeRegistries.BIOMES.getValues() to get all the biomes.


I believe this method would give all the biomes available in the game across all world types. To determine if a biome is for the nether or end, you can use the BiomeDictionary and use the getTypes() method to check if the biome is of Type.NETHER or Type.END. You could similarly use the dictionary to rule out any other categories of biome appropriate to your need.

I'll have to give that a shot. It should return the classes? (I'm only asking because I'm at work and not able to test it at this moment)

Posted (edited)
12 hours ago, jabelar said:

Sure it is a forge registry so the actual singleton instances are registered.

Does not work it seesm. Here is the way I've worked around it: https://pastebin.com/SS42VEK4

 

To basically accomplish the same thing as you can see on line 73 I've added a simple or classesList.isEmpty()

This will basically as you can see just check if the array is empty which and if it is spawn it in all biomes even those added by mods. I don't think this is too problematic. Although I am curious, what would be the best way to do this without the .isEmpty() check? Just for knowledge sake? UTilize the ForgeRegistries.BIOMES.getValues() to fetch all of them and store them into an array and call that? Example of pseudo code maybe if anyone cares to share? Also, no i have no idea where the format eraser is to stop the formatting problems on the text of my post after copy and pasting some code.

Edited by HalestormXV
Posted
12 minutes ago, HalestormXV said:

Also, no i have no idea where the format eraser is to stop the formatting problems on the text of my post after copy and pasting some code.

 

Use the TX button (fifth from the right) to clear formatting or use Ctrl-Shift-V to paste as plain text.

  • Like 1

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted
2 minutes ago, Choonster said:

 

Use the TX button (fifth from the right) to clear formatting or use Ctrl-Shift-V to paste as plain text.

Perfect, thank you very much. No idea how I missed that lol. I've only been here for about 3+ years now?

Posted (edited)
1 hour ago, HalestormXV said:

Does not work it seems.

It works fine for me. If I print the registry keys and values I get:

[21:59:22] [main/INFO] [STDOUT]: [com.blogspot.jabelarminecraft.examplemod.init.ModBiomes$RegistrationHandler:onEvent:56]: Registry key set = [minecraft:ocean, minecraft:plains, minecraft:desert, minecraft:extreme_hills, minecraft:forest, minecraft:taiga, minecraft:swampland, minecraft:river, minecraft:hell, minecraft:sky, minecraft:frozen_ocean, minecraft:frozen_river, minecraft:ice_flats, minecraft:ice_mountains, minecraft:mushroom_island, minecraft:mushroom_island_shore, minecraft:beaches, minecraft:desert_hills, minecraft:forest_hills, minecraft:taiga_hills, minecraft:smaller_extreme_hills, minecraft:jungle, minecraft:jungle_hills, minecraft:jungle_edge, minecraft:deep_ocean, minecraft:stone_beach, minecraft:cold_beach, minecraft:birch_forest, minecraft:birch_forest_hills, minecraft:roofed_forest, minecraft:taiga_cold, minecraft:taiga_cold_hills, minecraft:redwood_taiga, minecraft:redwood_taiga_hills, minecraft:extreme_hills_with_trees, minecraft:savanna, minecraft:savanna_rock, minecraft:mesa, minecraft:mesa_rock, minecraft:mesa_clear_rock, minecraft:void, minecraft:mutated_plains, minecraft:mutated_desert, minecraft:mutated_extreme_hills, minecraft:mutated_forest, minecraft:mutated_taiga, minecraft:mutated_swampland, minecraft:mutated_ice_flats, minecraft:mutated_jungle, minecraft:mutated_jungle_edge, minecraft:mutated_birch_forest, minecraft:mutated_birch_forest_hills, minecraft:mutated_roofed_forest, minecraft:mutated_taiga_cold, minecraft:mutated_redwood_taiga, minecraft:mutated_redwood_taiga_hills, minecraft:mutated_extreme_hills_with_trees, minecraft:mutated_savanna, minecraft:mutated_savanna_rock, minecraft:mutated_mesa, minecraft:mutated_mesa_rock, minecraft:mutated_mesa_clear_rock, examplemod:cloud]
[21:59:22] [main/INFO] [STDOUT]: [com.blogspot.jabelarminecraft.examplemod.init.ModBiomes$RegistrationHandler:onEvent:57]: Registry value list = [net.minecraft.world.biome.BiomeOcean@217fd3c, net.minecraft.world.biome.BiomePlains@1736273c, net.minecraft.world.biome.BiomeDesert@36eb8e07, net.minecraft.world.biome.BiomeHills@2a20da9f, net.minecraft.world.biome.BiomeForest@6f2864c3, net.minecraft.world.biome.BiomeTaiga@c2f7c63, net.minecraft.world.biome.BiomeSwamp@5cba890e, net.minecraft.world.biome.BiomeRiver@4d770bcd, net.minecraft.world.biome.BiomeHell@28a3fc34, net.minecraft.world.biome.BiomeEnd@7736c41e, net.minecraft.world.biome.BiomeOcean@5f911d24, net.minecraft.world.biome.BiomeRiver@3de383f7, net.minecraft.world.biome.BiomeSnow@31de27c, net.minecraft.world.biome.BiomeSnow@7ebfe01a, net.minecraft.world.biome.BiomeMushroomIsland@35c00c, net.minecraft.world.biome.BiomeMushroomIsland@6cd7dc74, net.minecraft.world.biome.BiomeBeach@20556566, net.minecraft.world.biome.BiomeDesert@e4ef4c0, net.minecraft.world.biome.BiomeForest@5ca8bd01, net.minecraft.world.biome.BiomeTaiga@7b10472e, net.minecraft.world.biome.BiomeHills@70e5737f, net.minecraft.world.biome.BiomeJungle@180cc0df, net.minecraft.world.biome.BiomeJungle@64f33dee, net.minecraft.world.biome.BiomeJungle@61c58320, net.minecraft.world.biome.BiomeOcean@10e4ee33, net.minecraft.world.biome.BiomeStoneBeach@13f182b9, net.minecraft.world.biome.BiomeBeach@5ee0cf64, net.minecraft.world.biome.BiomeForest@69c227fd, net.minecraft.world.biome.BiomeForest@14c5283, net.minecraft.world.biome.BiomeForest@1eb7ec59, net.minecraft.world.biome.BiomeTaiga@46748b04, net.minecraft.world.biome.BiomeTaiga@3e71a1f8, net.minecraft.world.biome.BiomeTaiga@5d4a34ff, net.minecraft.world.biome.BiomeTaiga@7cbede2b, net.minecraft.world.biome.BiomeHills@1ef04613, net.minecraft.world.biome.BiomeSavanna@215c6ec0, net.minecraft.world.biome.BiomeSavanna@2b19b346, net.minecraft.world.biome.BiomeMesa@4e789704, net.minecraft.world.biome.BiomeMesa@5751e53e, net.minecraft.world.biome.BiomeMesa@4e45fbd0, net.minecraft.world.biome.BiomeVoid@43b45ce4, net.minecraft.world.biome.BiomePlains@73e93c3a, net.minecraft.world.biome.BiomeDesert@1835b783, net.minecraft.world.biome.BiomeHills@456b140f, net.minecraft.world.biome.BiomeForest@2459333a, net.minecraft.world.biome.BiomeTaiga@1e6bd367, net.minecraft.world.biome.BiomeSwamp@2bd7f686, net.minecraft.world.biome.BiomeSnow@3601549f, net.minecraft.world.biome.BiomeJungle@5b2c7186, net.minecraft.world.biome.BiomeJungle@1b9c716f, net.minecraft.world.biome.BiomeForestMutated@33f2cf82, net.minecraft.world.biome.BiomeForestMutated@bea283b, net.minecraft.world.biome.BiomeForest@73852720, net.minecraft.world.biome.BiomeTaiga@22854f2b, net.minecraft.world.biome.BiomeTaiga@7ae0a26, net.minecraft.world.biome.BiomeTaiga@5ddf5118, net.minecraft.world.biome.BiomeHills@7b9d1a4, net.minecraft.world.biome.BiomeSavannaMutated@7845ee8a, net.minecraft.world.biome.BiomeSavannaMutated@5f35370b, net.minecraft.world.biome.BiomeMesa@16c8e9b8, net.minecraft.world.biome.BiomeMesa@7030b74c, net.minecraft.world.biome.BiomeMesa@27d6267e, com.blogspot.jabelarminecraft.examplemod.worldgen.BiomeCloud@4d34baec]

 

Edited by jabelar

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted
7 hours ago, jabelar said:

It works fine for me. If I print the registry keys and values I get:


[21:59:22] [main/INFO] [STDOUT]: [com.blogspot.jabelarminecraft.examplemod.init.ModBiomes$RegistrationHandler:onEvent:56]: Registry key set = [minecraft:ocean, minecraft:plains, minecraft:desert, minecraft:extreme_hills, minecraft:forest, minecraft:taiga, minecraft:swampland, minecraft:river, minecraft:hell, minecraft:sky, minecraft:frozen_ocean, minecraft:frozen_river, minecraft:ice_flats, minecraft:ice_mountains, minecraft:mushroom_island, minecraft:mushroom_island_shore, minecraft:beaches, minecraft:desert_hills, minecraft:forest_hills, minecraft:taiga_hills, minecraft:smaller_extreme_hills, minecraft:jungle, minecraft:jungle_hills, minecraft:jungle_edge, minecraft:deep_ocean, minecraft:stone_beach, minecraft:cold_beach, minecraft:birch_forest, minecraft:birch_forest_hills, minecraft:roofed_forest, minecraft:taiga_cold, minecraft:taiga_cold_hills, minecraft:redwood_taiga, minecraft:redwood_taiga_hills, minecraft:extreme_hills_with_trees, minecraft:savanna, minecraft:savanna_rock, minecraft:mesa, minecraft:mesa_rock, minecraft:mesa_clear_rock, minecraft:void, minecraft:mutated_plains, minecraft:mutated_desert, minecraft:mutated_extreme_hills, minecraft:mutated_forest, minecraft:mutated_taiga, minecraft:mutated_swampland, minecraft:mutated_ice_flats, minecraft:mutated_jungle, minecraft:mutated_jungle_edge, minecraft:mutated_birch_forest, minecraft:mutated_birch_forest_hills, minecraft:mutated_roofed_forest, minecraft:mutated_taiga_cold, minecraft:mutated_redwood_taiga, minecraft:mutated_redwood_taiga_hills, minecraft:mutated_extreme_hills_with_trees, minecraft:mutated_savanna, minecraft:mutated_savanna_rock, minecraft:mutated_mesa, minecraft:mutated_mesa_rock, minecraft:mutated_mesa_clear_rock, examplemod:cloud]
[21:59:22] [main/INFO] [STDOUT]: [com.blogspot.jabelarminecraft.examplemod.init.ModBiomes$RegistrationHandler:onEvent:57]: Registry value list = [net.minecraft.world.biome.BiomeOcean@217fd3c, net.minecraft.world.biome.BiomePlains@1736273c, net.minecraft.world.biome.BiomeDesert@36eb8e07, net.minecraft.world.biome.BiomeHills@2a20da9f, net.minecraft.world.biome.BiomeForest@6f2864c3, net.minecraft.world.biome.BiomeTaiga@c2f7c63, net.minecraft.world.biome.BiomeSwamp@5cba890e, net.minecraft.world.biome.BiomeRiver@4d770bcd, net.minecraft.world.biome.BiomeHell@28a3fc34, net.minecraft.world.biome.BiomeEnd@7736c41e, net.minecraft.world.biome.BiomeOcean@5f911d24, net.minecraft.world.biome.BiomeRiver@3de383f7, net.minecraft.world.biome.BiomeSnow@31de27c, net.minecraft.world.biome.BiomeSnow@7ebfe01a, net.minecraft.world.biome.BiomeMushroomIsland@35c00c, net.minecraft.world.biome.BiomeMushroomIsland@6cd7dc74, net.minecraft.world.biome.BiomeBeach@20556566, net.minecraft.world.biome.BiomeDesert@e4ef4c0, net.minecraft.world.biome.BiomeForest@5ca8bd01, net.minecraft.world.biome.BiomeTaiga@7b10472e, net.minecraft.world.biome.BiomeHills@70e5737f, net.minecraft.world.biome.BiomeJungle@180cc0df, net.minecraft.world.biome.BiomeJungle@64f33dee, net.minecraft.world.biome.BiomeJungle@61c58320, net.minecraft.world.biome.BiomeOcean@10e4ee33, net.minecraft.world.biome.BiomeStoneBeach@13f182b9, net.minecraft.world.biome.BiomeBeach@5ee0cf64, net.minecraft.world.biome.BiomeForest@69c227fd, net.minecraft.world.biome.BiomeForest@14c5283, net.minecraft.world.biome.BiomeForest@1eb7ec59, net.minecraft.world.biome.BiomeTaiga@46748b04, net.minecraft.world.biome.BiomeTaiga@3e71a1f8, net.minecraft.world.biome.BiomeTaiga@5d4a34ff, net.minecraft.world.biome.BiomeTaiga@7cbede2b, net.minecraft.world.biome.BiomeHills@1ef04613, net.minecraft.world.biome.BiomeSavanna@215c6ec0, net.minecraft.world.biome.BiomeSavanna@2b19b346, net.minecraft.world.biome.BiomeMesa@4e789704, net.minecraft.world.biome.BiomeMesa@5751e53e, net.minecraft.world.biome.BiomeMesa@4e45fbd0, net.minecraft.world.biome.BiomeVoid@43b45ce4, net.minecraft.world.biome.BiomePlains@73e93c3a, net.minecraft.world.biome.BiomeDesert@1835b783, net.minecraft.world.biome.BiomeHills@456b140f, net.minecraft.world.biome.BiomeForest@2459333a, net.minecraft.world.biome.BiomeTaiga@1e6bd367, net.minecraft.world.biome.BiomeSwamp@2bd7f686, net.minecraft.world.biome.BiomeSnow@3601549f, net.minecraft.world.biome.BiomeJungle@5b2c7186, net.minecraft.world.biome.BiomeJungle@1b9c716f, net.minecraft.world.biome.BiomeForestMutated@33f2cf82, net.minecraft.world.biome.BiomeForestMutated@bea283b, net.minecraft.world.biome.BiomeForest@73852720, net.minecraft.world.biome.BiomeTaiga@22854f2b, net.minecraft.world.biome.BiomeTaiga@7ae0a26, net.minecraft.world.biome.BiomeTaiga@5ddf5118, net.minecraft.world.biome.BiomeHills@7b9d1a4, net.minecraft.world.biome.BiomeSavannaMutated@7845ee8a, net.minecraft.world.biome.BiomeSavannaMutated@5f35370b, net.minecraft.world.biome.BiomeMesa@16c8e9b8, net.minecraft.world.biome.BiomeMesa@7030b74c, net.minecraft.world.biome.BiomeMesa@27d6267e, com.blogspot.jabelarminecraft.examplemod.worldgen.BiomeCloud@4d34baec]

 

Alright, so I probably used it wrong. So what would have to be done is this would have to be called and then all results stored into an array correct? And then in the code on line 45 you'd put in your array? Like I said, the .isEmpty() works fine and has the same effect, I am asking for my own knowledge sake.

Posted (edited)
2 hours ago, HalestormXV said:

Alright, so I probably used it wrong. So what would have to be done is this would have to be called and then all results stored into an array correct? And then in the code on line 45 you'd put in your array? Like I said, the .isEmpty() works fine and has the same effect, I am asking for my own knowledge sake.

So, you can get the registry instance in the RegistryEvent.Register<Biome> event. Even if you're not registering your own biome you can handle it. The event.getRegistry().getValues() returns a List<Biome> that can be stored in your own field for later reference. However, there is no guarantee that another mod isn't going to register more biomes after your chance to handle the event. So probably better to store the registry itself and grab the values later (maybe in the init loading phase) or if you're only looking up biomes occasionally performance probably isn't big concern and you can look it up whenever it makes sense.

 

So, the steps would be:

1) make a class that is registered as an event handler, and have a method that subscribes to the event bus that handles the RegistryEvent.Register<Biome> case. 

2) In that event handling method you would assign the registry to a public static field that you can access from elsewhere in your code.

 

So something like this:

/**
/* This class would probably also be the one where you register your own biomes, if you 
/* do that in your mod. Otherwise can be its own class dedicated for this purpose.
**/ 
@ObjectHolder(MainMod.MODID) // in case you're actually also registering biomes
public class ModBiomes
{
    // field to contain registry for later reference
    public final static IForgeRegistry<Biome> registry = null;

    @Mod.EventBusSubscriber(modid = MainMod.MODID)
    public static class RegistrationHandler
    {
        /**
         * Register this mod's {@link Biome}s.
         *
         * @param event The event
         */
        @SubscribeEvent
        public static void onEvent(final RegistryEvent.Register<Biome> event)
        {
            System.out.println("Storing biome registry");
            
            registry = event.getRegistry();

            // Register any of your own biomes here as well
            // example: registry.register(new BiomeCloud().setRegistryName(MainMod.MODID, ModWorldGen.CLOUD_NAME));
      
            // DEBUG
            System.out.println("Registry key set = " + registry.getKeys());
            System.out.println("Registry value list = " + registry.getValues());
        }
    }
}

 

Then later, you can just get the List<Biome> by referring to ModBiomes.registry.getValues(). Again I suggest you grab this in the init phase of your mod loading (where you'll be guaranteed that all other mods have added their biomes). You can put that list also into a public static field or not depending on how you intend to use the values.

Edited by jabelar
  • Like 2

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

Well, yes. But you need to follow Java practices for passing collections as varargs. I think generally you need a toArray() sort of conversion. This is explained in this article: http://programming.guide/java/passing-list-to-vararg-method.html

 

Also, I'm a bit confused on what you want. Do you want to actually generate the structures in ALL biomes? Remember that list will contain ocean and nether and so forth. But of course you can create your own sublists by removing stuff you don't want. In particular you can use the BiomeDictionary to help algorithmically filter out things by type.

  • Like 1

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted
2 hours ago, jabelar said:

Well, yes. But you need to follow Java practices for passing collections as varargs. I think generally you need a toArray() sort of conversion. This is explained in this article: http://programming.guide/java/passing-list-to-vararg-method.html

 

Also, I'm a bit confused on what you want. Do you want to actually generate the structures in ALL biomes? Remember that list will contain ocean and nether and so forth. But of course you can create your own sublists by removing stuff you don't want. In particular you can use the BiomeDictionary to help algorithmically filter out things by type.

thank you for that link. it will be most helpful. and yes i want the structures to spawn in all biomes which i’ve already achieved by simply adding a .isEmpty() check the the code segment where it checks for valid biomes. The not spawning in the ocean is handled by the last getTopBlock function so it will assure that only designated blocks will allow structure spawns. Also nether and end biomes are automatically checked by the switch statement that these are nested in. This is mainly for knowledge sake and alternative options so i can work better with biomes and fetching them in and of themselves. 

Posted
7 hours ago, jabelar said:

1) make a class that is registered as an event handler, and have a method that subscribes to the event bus that handles the RegistryEvent.Register<Biome> case. 

2) In that event handling method you would assign the registry to a public static field that you can access from elsewhere in your code.

 

Forge's registries are already stored in the ForgeRegistries class and you can use GameRegistry.findRegistry to find any other registry. There's no need to store the registry from the registry event for later use.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted
6 hours ago, Choonster said:

 

Forge's registries are already stored in the ForgeRegistries class and you can use GameRegistry.findRegistry to find any other registry. There's no need to store the registry from the registry event for later use.

You know when I was first answering this I actually wrote to use the ForgeRegistries.BIOMES but then edited it because I like to check in IDE when I give an answer and went looking for the ForgeRegistries class and couldn't find it so figured I'd "mis-remembered". The reason I couldn't find it was because it wasn't in the net.minecraftforge.registries package where I expected it and I didn't bother doing a java search since I didn't imagine there would be another place for it. But you're right, it is in the net.minecraftforge.common.registry package instead...

 

Okay, that is the easier way. 

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

Alright, I'll be honest, I've never used the GameRegistry.findRegistry or the ForgeRegistries.BIOMES so if you can provide any examples or even OpenSource code of its use on how to return the classes it'd be most helpful. I'm trying to learn the whole Registry thing.

Posted

You can think of a "registry" as simply a map. It might be implemented a bit more complicatedly but basically there are "entries" that have instances of a thing (which you are registering) and some sort of key (ID) to look it up. The point is that then you don't have to reference instances directly unless needed.

 

The entries can be simple in case of singleton classes. For an Item or Block, there is only one instance (per side) in the game so the registry for those references that instance directly. For things like Entities which have many instances in the game, there is the need to build a more complicaed entry which acts more like a factory -- when you get an entity from the registry you get a new one.

 

But for the purposes here, just think of the registries as a list of things (dimensions in this case) associated with a list of IDs. In most of the modern Forge registries the key/ID is actually a resource location made up of your modID plus the registry name.

 

So the rest is just regular Java. You can grab the registries from anywhere in your code since the classes are public. You should literally be able to write ForgeRegistries.BIOMES and your IDE should be able to use it provided your build paths are correct. I personally have Eclipse set up to automatically find the imports on saving, but you can also hover over anything and it should suggest an import. Is that what you mean when you say you can't get the classes?

 

So if you want a list of all biomes, you just say List<Biome> myList = ForgeRegistries.BIOMES.getValues().   Then you can do anything you would normally do with a Java list -- iterate through it, check if it contains() a value you care about and so forth. The list will contain actual Biome instances.

 

Anyway, bit confused on what the problem is. You have classes available with methods that we already explained give standard Java collections as return value. The rest is standard Java.

  • Like 1

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted (edited)
Spoiler

 

On 1/29/2018 at 11:37 AM, jabelar said:

You can think of a "registry" as simply a map. It might be implemented a bit more complicatedly but basically there are "entries" that have instances of a thing (which you are registering) and some sort of key (ID) to look it up. The point is that then you don't have to reference instances directly unless needed.

 

The entries can be simple in case of singleton classes. For an Item or Block, there is only one instance (per side) in the game so the registry for those references that instance directly. For things like Entities which have many instances in the game, there is the need to build a more complicaed entry which acts more like a factory -- when you get an entity from the registry you get a new one.

 

But for the purposes here, just think of the registries as a list of things (dimensions in this case) associated with a list of IDs. In most of the modern Forge registries the key/ID is actually a resource location made up of your modID plus the registry name.

 

So the rest is just regular Java. You can grab the registries from anywhere in your code since the classes are public. You should literally be able to write ForgeRegistries.BIOMES and your IDE should be able to use it provided your build paths are correct. I personally have Eclipse set up to automatically find the imports on saving, but you can also hover over anything and it should suggest an import. Is that what you mean when you say you can't get the classes?

 

So if you want a list of all biomes, you just say List<Biome> myList = ForgeRegistries.BIOMES.getValues().   Then you can do anything you would normally do with a Java list -- iterate through it, check if it contains() a value you care about and so forth. The list will contain actual Biome instances.

 

Anyway, bit confused on what the problem is. You have classes available with methods that we already explained give standard Java collections as return value. The rest is standard Java.

 

 

I got sidetracked on another part of my mod becasue this was frustrating me, and often when that is the case you step away and do something else. So hence why I have not responded. I did manage, after stepping away from this piece for a little while, to get a working method of what I was trying to accomplish. Basically I just wanted a way to Fetch the registered Biomes and get their classes. I needed the classes because the generate function requires the classes as a vararg. So the function I made can be tweaked and added to, to "filter" out your biomes, or just call it without any arguments to have your structures spawn in all Biomes. I needed the base function first though which was frustrating me. But nevertheless I managed to put this together: https://pastebin.com/1MWwgjCr if anyone is interested.

 

Feel free to comment, and criticize, or perhaps tell me this way of doing it is all wrong (and if that is the case let me know the correct way), or if it is inefficent and perhaps a more efficeint way of doing this, etc. etc. And yes alternatively i know you can just add an isEmpty() check and leave the last vararg blank and it will achieve the spawn in all biomes method but the point was to create a function so you can filter out biomes that you want.

Edited by HalestormXV
Posted (edited)
14 minutes ago, diesieben07 said:

Ok, where do I even start...

  • Do not use raw types.
  • Why in the f does getBiomeList return a List<?>?
  • Why are you storing the list of biomes in a field, but not the list of biome classes? Instead you convert to a list of classes every time...
  • ForgeRegistries.BIOMES.getValues().stream().map(Biome::getBiomeClass).collect(Collectors.toList())
  • You wrote that function... You can change it... Especially considering you are converting to a list inside the function anyways (in a very convoluted way, mind you...). Using classes here is a bad choice anyways, because one class can represent multiple different biomes. You should use a Set<Biome>.

Thank you for that and for providing the stream example. This is actually one of the functions I didn't write since I never worked with the structure spawning in this way, however I do see your point and its inefficency. But that is also what I get for following along with samples. Appreciate the feedback. I will be changing it up.

Edited by HalestormXV
Posted (edited)
2 hours ago, diesieben07 said:

It's in your code. It is your responsibility.

No arguments/reasons/excuses there. But that is why I post on these forums, because no matter how incompetant some of my posts may seem I always learn something from them lol. (Gently, or Harshly)

 

So the stream() basically renders the entire loop and array adding in the getBiomList useless which I see by utilizing the stream() and erasing that entire loop and add to array. Because what the

ForgeRegistries.BIOMES.getValues().stream().map(Biome::getBiomeClass).collect(Collectors.toList())

 

is essentially doing, is going into the Registry and pulling out all the Biomes that have been registered, getting their Values and placing them in a map which is storing their Class and the collector is basically collecting that entire map and turning it into a list, correct? So you can simply return that.

 

Now because it is turning it into a List I am imagining that you can work with it as a List just like any other list right?

Edited by HalestormXV

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • When I first heard about Bitcoin back in 2018, I was skeptical. The idea of a decentralized, digital currency seemed too good to be true. But I was intrigued as I learned more about the technology behind it and its potential. I started small, investing just a few hundred dollars, dipping my toes into the cryptocurrency waters. At first, it was exhilarating to watch the value of my investment grow exponentially. I felt like I was part of the future, an early adopter of this revolutionary new asset. But that euphoria was short-lived. One day, I logged into my digital wallet only to find it empty - my Bitcoin had vanished without a trace. It turned out that the online exchange I had trusted had been hacked, and my funds were stolen. I was devastated, both financially and emotionally. All the potential I had seen in Bitcoin was tainted by the harsh reality that with decentralization came a lack of regulation and oversight. My hard-earned money was gone, lost to the ether of the digital world. This experience taught me a painful lesson about the price of trust in the uncharted territory of cryptocurrency. While the technology holds incredible promise, the risks can be catastrophic if you don't approach it with extreme caution. My Bitcoin investment gamble had failed, and I was left to pick up the pieces, wiser but poorer for having placed my faith in the wrong hands. My sincere appreciation goes to MUYERN TRUST HACKER. You are my hero in recovering my lost funds. Send a direct m a i l ( muyerntrusted ( @ ) mail-me ( . )c o m ) or message on whats app : + 1 ( 4-4-0 ) ( 3 -3 -5 ) ( 0-2-0-5 )
    • You could try posting a log (if there is no log at all, it may be the launcher you are using, the FAQ may have info on how to enable the log) as described in the FAQ, however this will probably need to be reported to/remedied by the mod author.
    • So me and a couple of friends are playing with a shitpost mod pack and one of the mods in the pack is corail tombstone and for some reason there is a problem with it, where on death to fire the player will get kicked out of the server and the tombstone will not spawn basically deleting an entire inventory, it doesn't matter what type of fire it is, whether it's from vanilla fire/lava, or from modded fire like ice&fire/lycanites and it's common enough to where everyone on the server has experienced at least once or twice and it doesn't give any crash log. a solution to this would be much appreciated thank you!
    • It is 1.12.2 - I have no idea if there is a 1.12 pack
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.