How does a block know what type of tool broke it? How does it know the item was a pick instead of an axe? HarvestBlock function you can get the player's tool
How does a block know if an item is strong enough to break it? EnumToolMaterial
If you know this question it will help me more than the other two. How can you make a block drop a different item depending on the tool used to break it?
How do you load in textures from a separate terrain file or item file?
Where does Stone / dirt / Gravel ect get generated ? Say I wanted to have it generate snow instead of stone, where would I change that?
Looks like that was found
Anyone with experience with this, would like to give a bit of an explanation on how this file works?
to be clear I got most of the stuff at the bottom, I'm more interested with the stuff more towards the top of the file and the obfuscated stuff.
Another question, Where do caves get generated?
I think I found this one. I believe it to be MapGenCaves.java so unless I'm wrong this one is solved.
I suggest that you watch this. Its the second video to a small series of tutorials (the first video is just creating a new block), but he does explain briefly what each section does (inside the For Loops) and how to generate your own ore/block generation. The video is a ModLoader tutorial, but I guess the theory behind it is similar.
Once you have the code (and you have more of an understanding with it) try experimenting by changing some of the values. If the change doesn't work then there is always the undo button :wink.gif:
Be sure you back up your files too.
Hope this has helped in some way.
Helped a bit kinda already knew you could do things like that but did clear up a few things. But I was hoping for a more in-depth look at the class and more of the face functions. There's still some functions and variables with obfuscated names I'm guessing and well that's probable because no one knows exactly what they do I suppose.
I've been coding for years so I'm not afraid of something hard. just having the code still quite obfuscated makes things kinda frustrating. I've got quite a few of my things halfway working though. my biggest problem right now is that caves wont build in anything other that stone. So I need to find where they are being made so i can alter that.
It really isn't that hard if you take the time to look through it...
For generating new areas, search for:
public void populate
Below it you should see
if(rand.nextInt(4) == 0)
int i1 = k + rand.nextInt(16) + 8;
int l4 = rand.nextInt(128);
int i8 = l + rand.nextInt(16) + 8;
(new WorldGenLakes(Block.waterStill.blockID)).generate(worldObj, rand, i1, l4, i8);
if(rand.nextInt(8) == 0)
int j1 = k + rand.nextInt(16) + 8;
int i5 = rand.nextInt(rand.nextInt(120) + 8);
int j8 = l + rand.nextInt(16) + 8;
if(i5 < 64 || rand.nextInt(10) == 0)
(new WorldGenLakes(Block.lavaStill.blockID)).generate(worldObj, rand, j1, i5, j8);
What this is saying is when it's populating a new chunk, it first checks to see if a random number equals zero, if so, then a new body of water is added. Same thing with lava except it does a second check to see if the height is lower than 64 (underground) or if a random number between zero and ten is zero. The line that reads like this:
int l4 = rand.nextInt(128);
Is telling you what height the block will be found at. This says that water will be found anywhere from block 0 to block 128, in other words, anywhere.
Now to the next part. This is where *gasp* dungeons/caves are added.
for(int k1 = 0; k1 < 8; k1++)
int j5 = k + rand.nextInt(16) + 8;
int k8 = rand.nextInt(128);
int j11 = l + rand.nextInt(16) + 8;
(new WorldGenDungeons()).generate(worldObj, rand, j5, k8, j11);
It says here that it will loop through this snippet 9 times creating dungeons within the new area. It does it from anywhere on the map as we see the height being a max of 128.
Now for the mineable stuff.
for(int i2 = 0; i2 < 10; i2++)
int k5 = k + rand.nextInt(16);
int l8 = rand.nextInt(128);
int k11 = l + rand.nextInt(16);
(new WorldGenClay(32)).generate(worldObj, rand, k5, l8, k11);
Follows exact same principles as dungeon/cave generator.
Now here is something interesting! We have the controls to what continues to extend existing biomes. At the top of this method, there was this line:
BiomeGenBase biomegenbase = worldObj.getWorldChunkManager().getBiomeGenAt(k + 16, l + 16);
This gets the previous biome that was being created and sets it as the base for new generation.
Now we have the code that populates the biomes with things that fit in them such as bushes, flowers, mushrooms, cacti, etc... (small snippet here)
for(int i11 = 0; i11 < l7; i11++)
int l13 = k + rand.nextInt(16) + 8;
int j14 = l + rand.nextInt(16) + 8;
WorldGenerator worldgenerator = biomegenbase.getRandomWorldGenForTrees(rand);
worldgenerator.func_517_a(1.0D, 1.0D, 1.0D);
worldgenerator.generate(worldObj, rand, l13, worldObj.getHeightValue(l13, j14), j14);
This is rather like the previous code, no? It first gets how it generates trees using the method inside biomegenbase called "getRandomWorldGenForTrees(int)". This controls the differences between the biomes in tree quantity, distance between, etc... Then we see this:
Yeah I a saw most of that looked mostly self explanatory. I was actually more interested in the stuff all above all that the ones with the obfuscated functions and such in them. The base stuff. Are you sure that WorldGenDungeons does caves as well? I guess I just assumed that it was only dungeons... Thanks for the biome stuff though I hadn't taken the time to look into those yet.