Alright, so in my mod i plan on eventually adding in my own custom generating structure. but I dont know how exactly to do that so right now im just trying to learn the basics by testing it out on mineshafts. Sense I have my own custom wood and mineshafts spawn anyways i thought that i should change the wood out to be more appropriate. Problem is that i dont know if mineshafts spawn anymore, because I have searched many caves throughout the world and I have yet to spot one. So i was just wondering if im generating them correctly, or if theres a simpler way to generate them. I really appreciate the help in advanced. And im sorry if im trying something out of my league, but I thought that by doing so it would be the only way to truly learn how to create and generate a structure.
Are you trying to spawn one that randomly generates, or one that always has the same shape? Since you're mentioning mineshafts, I suspect it may be the former, and I'm not too familiar with how the whole "random generation" part works, however I have made a structure that spawns at random locations in the world. It also looks like you're trying to rewrite the entire chunk generation. This probably isn't necessary- I've been able to make several structures that spawn in the world without overriding the chunk provider. If you want to keep doing it this way, it's probably possible- but I can't help you there because I've hardly played with chunk providers and stuff
Also note that this code was written in 1.7.2. Some functions may be slightly different from then to 1.7.10 (not positive...), but the principles remain the same.
In regards to how "proper" this code is, I'm not certain- but I do know that it works. It doesn't use quite the same methods as Minecraft's generation, but it is fully functional. The way I wrote out everything block by block is, admittedly, rather cumbersome, however I like it for testing purposes because it makes it easier to change individual blocks. If I ever do anything serious with the mod I may use a less cumbersome function, but this works for now.
Feel free to steal my code- I don't mind Just please do give me credit to me if you use a large portion of it. I'm not going to come after you with a pitchfork if you don't, but I put a great deal of time and effort into writing this up so it would be nice to be credited for it
Also, if you want to pop either of these pieces of code directly into your mod just to test, make sure you change the entities it's trying to spawn! These files use custom entities from the mod I was trying to make, and I'm pretty sure it will crash your game if you don't change it.
Now, the one thing about these is that they spawn virtually the same structure each time. If you want a lot of variation between structures (like mineshafts, strongholds, and villages in Vanilla), you'll have to code something up for that. But I hope this at least gives you somewhere to start
One more thing. You mentioned feeling like this might be "out of your league". Even if that's the case, don't give up! When I started modding, I had literally never touched or seen Java before. I had a little experience with C#, but that was it. Now, I know I still have a ton to learn (heck, I've made probably 5 topics in this forum in the last week because of questions :P), and I'm certainly by no means an expert, but I've come a long way from where I started. I'm doing things now that I've never even dreamed of doing back when I first started modding. And honestly, most of my knowledge comes from internet tutorials. I know there are people who would disagree, but for me, modding has been a great way to learn code. Don't get discouraged just because you don't know something. After all, every time there's something you don't know, you've just been given an opportunity to learn
I agree, i learnt java by coding my mod and with help and video tutorials. Even though others say I should learn java first then go into modding, I jumped into modding and used tutorials to help me get what I want or at least the foundation to get started on it. Follow your heart, don't follow what others advises you to do as you may never learn by following their advice. It's your choirce really, I've come a long and still got much to learn. Don't give up and co tinue to try it! Work on the result you want to achieve! All the best and good luck!
I agree, i learnt java by coding my mod and with help and video tutorials. Even though others say I should learn java first then go into modding, I jumped into modding and used tutorials to help me get what I want or at least the foundation to get started on it. Follow your heart, don't follow what others advises you to do as you may never learn by following their advice. It's your choirce really, I've come a long and still got much to learn. Don't give up and co tinue to try it! Work on the result you want to achieve! All the best and good luck!
There are very good reasons we advise learning Java before starting modding, please do not spread misinformation. Without at least a basic understanding of Java, you will constantly run into problems due to lack of understanding. Be patient and don't rush into it, you will get to the more interesting stuff soon enough. Below are two links which help explain the basic concepts needed to program in Java: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/index.html https://docs.oracle.com/javase/tutorial/java/concepts/index.html
Rollback Post to RevisionRollBack
Please don't PM me asking for help, I will just redirect you to the appropriate forum, where there are others who are far more skilled than me.
There are very good reasons we advise learning Java before starting modding, please do not spread misinformation. Without at least a basic understanding of Java, you will constantly run into problems due to lack of understanding. Be patient and don't rush into it, you will get to the more interesting stuff soon enough. Below are two links which help explain the basic concepts needed to program in Java: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/index.html https://docs.oracle.com/javase/tutorial/java/concepts/index.html
Yeah, no one's saying not to learn at least some Java O.o But there's also a lot you can learn about Java through modding. And I do speak from experience...
I know the basics of coding. I took a programming class earlier this year. True its not java specifically, but it was the basics such as arrays, if else, case select, and so on.
And the reason I have my own chunk provider is because it's my own dimension. And when i first created it from a modding tutorial I found that making my own chunk provider (because I have my own custom world blocks) was the easiest way to do so.
And the reason I have my own chunk provider is because it's my own dimension. And when i first created it from a modding tutorial I found that making my own chunk provider (because I have my own custom world blocks) was the easiest way to do so.
Ohhhhhh, in that case you do need your own chunk provider Makes sense now And ah, congrats! Looks like a cool mineshaft, btw
Technically I think my code *would* work for a custom dimension, but I'm not positive... if you wanna play with it, go ahead, but it seems like your method is working just fine so you my want to stick with that for the time being
I just wanted to check if this code was working. I know that the structure generates. But im unable to find it when I changed my code. Im not sure if its just not spawning, or if it's spawning deep underground without my knowledge. Am i missing something?
If you're not sure if something is generating, the easiest way to find out is not to go searching all over the world for it, but to put a System.out.println("My X structure generated at x/y/z coordinates") in your generation code, then check the console while you generate chunks.
If you're not sure if something is generating, the easiest way to find out is not to go searching all over the world for it, but to put a System.out.println("My X structure generated at x/y/z coordinates") in your generation code, then check the console while you generate chunks.
I'd do this even if you do locate your structure. It will help you first of all know if they're spawning, second of all where they're spawning (so they aren't too deep underground or flying in the sky if you don't want it that way), and thirdly how many are spawning. It's very useful for getting the right amount of structures to spawn, I've found.
I'd give an example in the code I sent but unfortunately this is the old version. I made this right before I switched to 1.8, so the print stuff is all in the new code
have I ever had some common sense? I threw out common sense out a long time ago when I started to create a dimension made entirely out of chocolate blocks. xD
Is it returning an error? What exactly is it printing?
My guess would be that you have your print statement before it actually goes to get the coordinates. At least that's how it looks- your code is styled differently from mine. Try putting it just before your return true statement in canSpawnStructureAtCoords and see if that helps
static int xCoord? And just what good do you think that will do you? O.o
You need to use the coordinates that are sent to the method that actually generates the structure at a specific position, i.e. the Start class constructor that builds everything.
It would help if you renamed the parameters:
// meaningless parameter names:
public Start(World p_i2040_1_, Random p_i2040_2_, int p_i2040_3_, int p_i2040_4_)
// meaningful parameter names:
public Start(World world, Random rand, int chunkX, int chunkZ)
That makes it much more obvious what's going on, for example '(p_i2040_3_ << 4)' actually makes sense after renaming: '(chunkX << 4)', which is translating the chunk coordinate into a block coordinate, which is one of the ones you will want to print to the screen.
Alright, so in my mod i plan on eventually adding in my own custom generating structure. but I dont know how exactly to do that so right now im just trying to learn the basics by testing it out on mineshafts. Sense I have my own custom wood and mineshafts spawn anyways i thought that i should change the wood out to be more appropriate. Problem is that i dont know if mineshafts spawn anymore, because I have searched many caves throughout the world and I have yet to spot one. So i was just wondering if im generating them correctly, or if theres a simpler way to generate them. I really appreciate the help in advanced. And im sorry if im trying something out of my league, but I thought that by doing so it would be the only way to truly learn how to create and generate a structure.
ChunkProviderChocolate
MapGenChocolateMineshaft
StructureChocolateMineshafStart
StructureChocolateMineshaftPieces
MapGenChocolateStructureIO
ChocolateStructureStart
MapGenChocolateStructure
ChocolateStructureComponents
Are you trying to spawn one that randomly generates, or one that always has the same shape? Since you're mentioning mineshafts, I suspect it may be the former, and I'm not too familiar with how the whole "random generation" part works, however I have made a structure that spawns at random locations in the world. It also looks like you're trying to rewrite the entire chunk generation. This probably isn't necessary- I've been able to make several structures that spawn in the world without overriding the chunk provider. If you want to keep doing it this way, it's probably possible- but I can't help you there because I've hardly played with chunk providers and stuff
Also note that this code was written in 1.7.2. Some functions may be slightly different from then to 1.7.10 (not positive...), but the principles remain the same.
Nether Dog Dungeon (spawns in the Nether!)
Old Ruin (spawns in the Overworld)
This structure gen file tells the world provider where to generate the structures.
StructureGen
Finally, you need to place this code into your init function in your main mod file:
GameRegistry.registerWorldGenerator(new StructureGen(), 5);
In regards to how "proper" this code is, I'm not certain- but I do know that it works. It doesn't use quite the same methods as Minecraft's generation, but it is fully functional. The way I wrote out everything block by block is, admittedly, rather cumbersome, however I like it for testing purposes because it makes it easier to change individual blocks. If I ever do anything serious with the mod I may use a less cumbersome function, but this works for now.
Feel free to steal my code- I don't mind Just please do give me credit to me if you use a large portion of it. I'm not going to come after you with a pitchfork if you don't, but I put a great deal of time and effort into writing this up so it would be nice to be credited for it
Also, if you want to pop either of these pieces of code directly into your mod just to test, make sure you change the entities it's trying to spawn! These files use custom entities from the mod I was trying to make, and I'm pretty sure it will crash your game if you don't change it.
Now, the one thing about these is that they spawn virtually the same structure each time. If you want a lot of variation between structures (like mineshafts, strongholds, and villages in Vanilla), you'll have to code something up for that. But I hope this at least gives you somewhere to start
One more thing. You mentioned feeling like this might be "out of your league". Even if that's the case, don't give up! When I started modding, I had literally never touched or seen Java before. I had a little experience with C#, but that was it. Now, I know I still have a ton to learn (heck, I've made probably 5 topics in this forum in the last week because of questions :P), and I'm certainly by no means an expert, but I've come a long way from where I started. I'm doing things now that I've never even dreamed of doing back when I first started modding. And honestly, most of my knowledge comes from internet tutorials. I know there are people who would disagree, but for me, modding has been a great way to learn code. Don't get discouraged just because you don't know something. After all, every time there's something you don't know, you've just been given an opportunity to learn
Hope this helps, and happy modding!
I agree, i learnt java by coding my mod and with help and video tutorials. Even though others say I should learn java first then go into modding, I jumped into modding and used tutorials to help me get what I want or at least the foundation to get started on it. Follow your heart, don't follow what others advises you to do as you may never learn by following their advice. It's your choirce really, I've come a long and still got much to learn. Don't give up and co tinue to try it! Work on the result you want to achieve! All the best and good luck!
There are very good reasons we advise learning Java before starting modding, please do not spread misinformation. Without at least a basic understanding of Java, you will constantly run into problems due to lack of understanding. Be patient and don't rush into it, you will get to the more interesting stuff soon enough. Below are two links which help explain the basic concepts needed to program in Java:
https://docs.oracle.com/javase/tutorial/java/nutsandbolts/index.html
https://docs.oracle.com/javase/tutorial/java/concepts/index.html
Please don't PM me asking for help, I will just redirect you to the appropriate forum, where there are others who are far more skilled than me.
This is not the signature you are looking for.
Banners and such things
Yeah, no one's saying not to learn at least some Java O.o But there's also a lot you can learn about Java through modding. And I do speak from experience...
I know the basics of coding. I took a programming class earlier this year. True its not java specifically, but it was the basics such as arrays, if else, case select, and so on.
And the reason I have my own chunk provider is because it's my own dimension. And when i first created it from a modding tutorial I found that making my own chunk provider (because I have my own custom world blocks) was the easiest way to do so.
on the bright side I just found my mineshaft.
Now ill try to make my own custom structure. not really sure what a chocolate factory looks like though. xD
Ohhhhhh, in that case you do need your own chunk provider Makes sense now And ah, congrats! Looks like a cool mineshaft, btw
Technically I think my code *would* work for a custom dimension, but I'm not positive... if you wanna play with it, go ahead, but it seems like your method is working just fine so you my want to stick with that for the time being
alright, im going to try to get a custom house to spawn in my dimension.
Ah, best of luck!
I just wanted to check if this code was working. I know that the structure generates. But im unable to find it when I changed my code. Im not sure if its just not spawning, or if it's spawning deep underground without my knowledge. Am i missing something?
MapGenChocolateBridge
If you're not sure if something is generating, the easiest way to find out is not to go searching all over the world for it, but to put a System.out.println("My X structure generated at x/y/z coordinates") in your generation code, then check the console while you generate chunks.
I'd do this even if you do locate your structure. It will help you first of all know if they're spawning, second of all where they're spawning (so they aren't too deep underground or flying in the sky if you don't want it that way), and thirdly how many are spawning. It's very useful for getting the right amount of structures to spawn, I've found.
I'd give an example in the code I sent but unfortunately this is the old version. I made this right before I switched to 1.8, so the print stuff is all in the new code
Well I know that its generating. but I dont know where it is generating....
... you're supposed to replace the literal 'x/y/z' with the coordinates at which it generated... use some common sense.
have I ever had some common sense? I threw out common sense out a long time ago when I started to create a dimension made entirely out of chocolate blocks. xD
I havent been very successful with trying to find the coordinates....
MapGenChocolateBridge
Is it returning an error? What exactly is it printing?
My guess would be that you have your print statement before it actually goes to get the coordinates. At least that's how it looks- your code is styled differently from mine. Try putting it just before your return true statement in canSpawnStructureAtCoords and see if that helps
You need to use the coordinates that are sent to the method that actually generates the structure at a specific position, i.e. the Start class constructor that builds everything.
It would help if you renamed the parameters: That makes it much more obvious what's going on, for example '(p_i2040_3_ << 4)' actually makes sense after renaming: '(chunkX << 4)', which is translating the chunk coordinate into a block coordinate, which is one of the ones you will want to print to the screen.