I am working on a mod for which I must generate a single instance of a specific feature somewhere in the middle of each biome. Or, well, in those instances where there are really massive biomes, it could consider it two adjacent biomes and generate two of the features. I have been considering ways to go about this, and have come up with several options. I am, however, legitimately uncertain which would work best. There may be considerations or options I have not thought of. So I wished to get some input from the community.
The options I have come up with are:
Look for adjacent chunks sharing a biome, roughly calculate the center, and generate the feature. Problem here is when it's generating chunks as you explore... how does it know what will be but is not yet generated? It doesn't.
Generate a special, single-chunk biome variant that cannot be at the edge of a cluster. It doesn't have to be in the exact center, just not too close to the edge. I feel like this is probably the best I've thought of, although I'm not 100% certain how to go about it. I believe Twilight Forest does something with "center" biome variants, but I don't know if it cares about how many spawn in a given biome.
This is kind of a variant of either of the above, but just when it's generating a new chunk look for a certain number of the same connected biome chunks. If it finds enough, it either generates the alternate chunk or just puts the feature in the new chunk. I guess it would then have to generate a certain number more of the chunks before it could put a new feature in, IF it sticks to the same biome type for long enough. This seems like it could cause problems with too many of the features, though. I want every biome to have one, but given how large contiguous biomes are on average... that leaves them uncommon enough for my purposes.
So, the idea being a plains would have a plains variant of the feature somewhere within. Same for each biome. Any advice or input would be very much appreciated here. Thanks!
I think #2 would be the easiest to add to your own biomes. You can look at how Mega Taiga only spawns in the middle of Taiga, for instance, to see how that would work. ( Although the biome code is a pain to read... )
However, if you are adding these features to existing biomes such as plains, it may be harder. Or maybe not. I'm not sure.
You could also save locations of each biome-specific structure in the WorldSaveData and check against those whenever that biome is generated. That way, you could only generate if there is a large enough distance between 2 structures.
Rollback Post to RevisionRollBack
Click this banner for a list of illegal mod distributors -- only download from legal sites!
The biome code is a pain and a half to read, I agree. Which is why I tend to look at other modders more than the original source, but it sounds like the Mega Taiga would be a good place to start.
I keep thinking there must be a simpler way to do this, but it escapes me if so. Maybe if I gave more details but I don't want to make the project too obvious yet. I want one of these features per biome because it has to do with the magic system. These features are kind of the core of the biome, and things affecting the biome are manifest there. And vice versa.
EDIT: I just reread your post and that bit about the WorldSaveData just jumped out at me. That is something that hadn't occurred to me at all. A combination of that and checking to make sure it doesn't spawn at the very edge of a biome should be pretty simple, I think.
I just reread your post and that bit about the WorldSaveData just jumped out at me. That is something that hadn't occurred to me at all. A combination of that and checking to make sure it doesn't spawn at the very edge of a biome should be pretty simple, I think.
WorldSavedData is fairly easy to add, just add a class that extends WorldSavedData and overrides writeToNBT and readFromNBT . I usually add a helper method to get the current save data -- see here. To change the saveable data, call that helper method to get the instance from the world, then change instance variables from there (recommended to use setter-methods that call markDirty() and only change the data server-side)
Rollback Post to RevisionRollBack
Click this banner for a list of illegal mod distributors -- only download from legal sites!
Thanks for your help, Sky. It has been most appreciated. Unfortunately, I'm way too prone to second-guessing myself and I'm not even confident that what I planned is the best way to even handle it anymore. I need to regain confidence in my mechanics >.<
I'm gonna stick some brief notes on the problem/project in a spoiler, so if you or anyone else wants to call me out on a stupid mechanic idea you can xD Any input is most appreciated. Prolly overthinking this...
So the project I'm working on is a Magic the Gathering mod. I've got some basic resources and mechanics done, but before I go any further I need to figure out how I'm gonna handle mana. If you don't know how that works in MTG, I'll give a short summary:
Mana is generated by the land, which is tapped through a mage's "soul bond" with said land. They forge said bonds simply by traveling, exploring, and spending time in places. You have to be there to forge the bond, but then it works across any distance. Mana comes in five distinct colors, and then generic colorless mana. The different colors are generated by different kinds of landscapes. White comes from plains, blue is generated by islands, black is drawn from swamps, red from mountains, and last green grows in forests!
You've probably seen where I'm going with this. Biomes are the lands. Exploring and forging soul bonds with different biomes is how you generate mana. The features I asked about generating before were to represent the Soul Bonds, and would have looked something a little like Thaumcraft Aura Nodes... but bigger and more galaxy-y. Problem being, and I don't know why I didn't stop to think about this sooner... well, I realized that despite my desire to have something to interact with, that's not very lore-friendly nor game friendly; who wants to load chunks to have their mana?
Plus, wanting something to interact with was silly in the first place. You're not ever going to directly interact with the soul bond, not really. I planned to have enchantments or curses as features generated on the land, that you could either dispel or cast. But it doesn't really make sense for those to be location-based, either. They're attached to the Soul Bond and the entirety of the land.
So now everything is arbitrary properties attached to locations with maybe a ghostly marker feature that doesn't actually do anything. All of that tied to a player. I'm not really so sure how to go about that. Blood Magic's demon will came to mind, but that's only tied to a chunk, not a player. So kind of the same problem as before, the only improvement being a lack of a feature and attaching things directly to a chunk.
I'm probably overhtinking this. That's always been a problem of mine.
EDIT: Waiiiiit... Blood Magic... Soul Network...
EDIT: WorldSavedData won't exactly work for that, will it? It's not strictly world locations anymore. Dang it... looks like I have a lot of reading to do...
See this tutorial for how to save information per-player, using IEntityExtendedProperties . You can maybe use player tick events to detect "new" areas and add mana to the player accordingly. I have played MTG before, so I think I understand what you want to do.
Rollback Post to RevisionRollBack
Click this banner for a list of illegal mod distributors -- only download from legal sites!
I found that tutorial of CoolAlias, and it was very helpful. Thank you for pointing me to it, anyway, it's good to know there are people as helpful as you out there and your effort is most appreciated. I think that would certainly work for a basic mechanic, and is acceptable.
Ideally... is there any construction you know of that can store data tied to a chunk location, without actually requiring the chunk to be loaded? Because it occurred to me, if I can get the players working with IExtendedData that taps into a list of the locations, then multiple people can tap into a single land and actually tap it out. The idea being the land can store X mana, and the soul bond has to recharge for Y seconds before the same person can tap a mana. The mana regenerates at about the same rate (Y), but if you have multiple people straining a single land you can tap it out and cause the land to enter a recovery period where it won't generate mana.
For lands that enter the battlefield tapped, I was just going to have the soul bond have a stabiliation period of like... 5Y before you can actually use it. The question is, is that mechanic actually worth setting up? Or do you think it's too much of a hassle/bother/burden on the server?
EDIT: I think I figured it out, thanks for your help :3
I am working on a mod for which I must generate a single instance of a specific feature somewhere in the middle of each biome. Or, well, in those instances where there are really massive biomes, it could consider it two adjacent biomes and generate two of the features. I have been considering ways to go about this, and have come up with several options. I am, however, legitimately uncertain which would work best. There may be considerations or options I have not thought of. So I wished to get some input from the community.
The options I have come up with are:
So, the idea being a plains would have a plains variant of the feature somewhere within. Same for each biome. Any advice or input would be very much appreciated here. Thanks!
I think #2 would be the easiest to add to your own biomes. You can look at how Mega Taiga only spawns in the middle of Taiga, for instance, to see how that would work. ( Although the biome code is a pain to read... )
However, if you are adding these features to existing biomes such as plains, it may be harder. Or maybe not. I'm not sure.
You could also save locations of each biome-specific structure in the WorldSaveData and check against those whenever that biome is generated. That way, you could only generate if there is a large enough distance between 2 structures.
The biome code is a pain and a half to read, I agree. Which is why I tend to look at other modders more than the original source, but it sounds like the Mega Taiga would be a good place to start.
I keep thinking there must be a simpler way to do this, but it escapes me if so. Maybe if I gave more details but I don't want to make the project too obvious yet. I want one of these features per biome because it has to do with the magic system. These features are kind of the core of the biome, and things affecting the biome are manifest there. And vice versa.
EDIT: I just reread your post and that bit about the WorldSaveData just jumped out at me. That is something that hadn't occurred to me at all. A combination of that and checking to make sure it doesn't spawn at the very edge of a biome should be pretty simple, I think.
WorldSavedData is fairly easy to add, just add a class that extends WorldSavedData and overrides writeToNBT and readFromNBT . I usually add a helper method to get the current save data -- see here. To change the saveable data, call that helper method to get the instance from the world, then change instance variables from there (recommended to use setter-methods that call markDirty() and only change the data server-side)
Thanks for your help, Sky. It has been most appreciated. Unfortunately, I'm way too prone to second-guessing myself and I'm not even confident that what I planned is the best way to even handle it anymore. I need to regain confidence in my mechanics >.<
I'm gonna stick some brief notes on the problem/project in a spoiler, so if you or anyone else wants to call me out on a stupid mechanic idea you can xD Any input is most appreciated. Prolly overthinking this...
So the project I'm working on is a Magic the Gathering mod. I've got some basic resources and mechanics done, but before I go any further I need to figure out how I'm gonna handle mana. If you don't know how that works in MTG, I'll give a short summary:
Mana is generated by the land, which is tapped through a mage's "soul bond" with said land. They forge said bonds simply by traveling, exploring, and spending time in places. You have to be there to forge the bond, but then it works across any distance. Mana comes in five distinct colors, and then generic colorless mana. The different colors are generated by different kinds of landscapes. White comes from plains, blue is generated by islands, black is drawn from swamps, red from mountains, and last green grows in forests!
You've probably seen where I'm going with this. Biomes are the lands. Exploring and forging soul bonds with different biomes is how you generate mana. The features I asked about generating before were to represent the Soul Bonds, and would have looked something a little like Thaumcraft Aura Nodes... but bigger and more galaxy-y. Problem being, and I don't know why I didn't stop to think about this sooner... well, I realized that despite my desire to have something to interact with, that's not very lore-friendly nor game friendly; who wants to load chunks to have their mana?
Plus, wanting something to interact with was silly in the first place. You're not ever going to directly interact with the soul bond, not really. I planned to have enchantments or curses as features generated on the land, that you could either dispel or cast. But it doesn't really make sense for those to be location-based, either. They're attached to the Soul Bond and the entirety of the land.
So now everything is arbitrary properties attached to locations with maybe a ghostly marker feature that doesn't actually do anything. All of that tied to a player. I'm not really so sure how to go about that. Blood Magic's demon will came to mind, but that's only tied to a chunk, not a player. So kind of the same problem as before, the only improvement being a lack of a feature and attaching things directly to a chunk.
I'm probably overhtinking this. That's always been a problem of mine.
EDIT: Waiiiiit... Blood Magic... Soul Network...
EDIT: WorldSavedData won't exactly work for that, will it? It's not strictly world locations anymore. Dang it... looks like I have a lot of reading to do...
See this tutorial for how to save information per-player, using IEntityExtendedProperties . You can maybe use player tick events to detect "new" areas and add mana to the player accordingly. I have played MTG before, so I think I understand what you want to do.
I found that tutorial of CoolAlias, and it was very helpful. Thank you for pointing me to it, anyway, it's good to know there are people as helpful as you out there and your effort is most appreciated. I think that would certainly work for a basic mechanic, and is acceptable.
Ideally... is there any construction you know of that can store data tied to a chunk location, without actually requiring the chunk to be loaded? Because it occurred to me, if I can get the players working with IExtendedData that taps into a list of the locations, then multiple people can tap into a single land and actually tap it out. The idea being the land can store X mana, and the soul bond has to recharge for Y seconds before the same person can tap a mana. The mana regenerates at about the same rate (Y), but if you have multiple people straining a single land you can tap it out and cause the land to enter a recovery period where it won't generate mana.
For lands that enter the battlefield tapped, I was just going to have the soul bond have a stabiliation period of like... 5Y before you can actually use it. The question is, is that mechanic actually worth setting up? Or do you think it's too much of a hassle/bother/burden on the server?
EDIT: I think I figured it out, thanks for your help :3