MC Modding
Please register and join the community!

[1.8.1] Generating Ores

View previous topic View next topic Go down

[1.8.1] Generating Ores

Post by Strengthowns on Wed Oct 05, 2011 10:54 am

Generating Ores

Spoiler:
mod_Namehere

Code:
    public void GenerateSurface(World world, Random rand, int chunkX, int chunkZ)
    {
        for(int i = 0; i < RARITY; i++)
        {
            int randPosX = chunkX + rand.nextInt(16);
            int randPosY = rand.nextInt(HEIGHT ABOVE BEDROCK);
            int randPosZ = chunkZ + rand.nextInt(16);
            (new WorldGenMinable(mod_Namehere.Namehere.blockID, VEIN SIZE)).generate(world, rand, randPosX, randPosY, randPosZ);
        }
    } 

Help: mod_Namehere

1. Put this bit of code outside all of the modloader stuff.

2. RARITY is... how rare it is. For reference coal is 20.

3. HEIGHT ABOVE BEDROCK is self explanatory. If you set it to 20, you can find it generating 20 levels above bedrock.

4. VEIN SIZE is the max amount that it generates together.

5. The mod_Namehere.Namehere.blockID is what block it generates.

6. Enjoy your new generating ore!
avatar
Strengthowns
Admin

Posts : 79
Join date : 2011-06-14
Location : Right here!

View user profile http://www.mcmodding.4umer.com

Back to top Go down

Re: [1.8.1] Generating Ores

Post by ikke009 on Thu Oct 27, 2011 11:42 am

how does the rarity work? if coal is 20, would diamond be higher or lower?
avatar
ikke009
Member

Posts : 65
Join date : 2011-10-24
Age : 22
Location : The netherlands

View user profile

Back to top Go down

Re: [1.8.1] Generating Ores

Post by groxmapper on Thu Oct 27, 2011 1:31 pm

Strengthowns wrote:
Generating Ores

Spoiler:
mod_Namehere

Code:
    public void GenerateSurface(World world, Random rand, int chunkX, int chunkZ)
    {
        for(int i = 0; i < RARITY; i++)
        {
            int randPosX = chunkX + rand.nextInt(16);
            int randPosY = rand.nextInt(HEIGHT ABOVE BEDROCK);
            int randPosZ = chunkZ + rand.nextInt(16);
            (new WorldGenMinable(mod_Namehere.Namehere.blockID, VEIN SIZE)).generate(world, rand, randPosX, randPosY, randPosZ);
        }
    } 

Help: mod_Namehere

1. Put this bit of code outside all of the modloader stuff.

2. RARITY is... how rare it is. For reference coal is 20.

3. HEIGHT ABOVE BEDROCK is self explanatory. If you set it to 20, you can find it generating 20 levels above bedrock.

4. VEIN SIZE is the max amount that it generates together.

5. The mod_Namehere.Namehere.blockID is what block it generates.

6. Enjoy your new generating ore!

I would like to note this doesn't work with generateNether because WorldGenMinable replaces smooth stone when placing the ores so you'll need to copy WorldGenMineable and edit that to be netherrack for nether ore spawning.
avatar
groxmapper
Member

Posts : 27
Join date : 2011-10-24

View user profile

Back to top Go down

Re: [1.8.1] Generating Ores

Post by lcass on Thu Oct 27, 2011 7:07 pm

diamond is 7 and i think in ic2 uranium is 10

lcass
Member

Posts : 145
Join date : 2011-10-24
Location : england

View user profile http://www.youtube.com/user/thealcasgroup

Back to top Go down

Re: [1.8.1] Generating Ores

Post by lcass on Thu Oct 27, 2011 7:30 pm

I noticed people found generating ores hard so here is the full code with all the fixes
Code:
package net.minecraft.src;

import java.util.Random;

public class mod_rubyore extends BaseMod
{
  public static Block rubyore = new rubyore(195, 0).setHardness(1.0F).setResistance(300.0F).setLightValue(1.0F).setBlockName("rubyore");
 
  public String Version()
  {
      return "1.8.1";
  }
 
  public mod_rubyore()
  {
      ModLoader.RegisterBlock(rubyore);
      rubyore.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/crystal/rubyore.png");
      ModLoader.AddName(rubyore, "rubyore");
   
  }
  public void GenerateSurface(World world, Random rand, int chunkX, int chunkZ)
  {
      for(int i = 0; i < 6; i++)
      {
          int randPosX = chunkX + rand.nextInt(16);
          int randPosY = rand.nextInt(30 );
          int randPosZ = chunkZ + rand.nextInt(16);
          (new WorldGenMinable(mod_rubyore.rubyore.blockID, 2)).generate(world, rand, randPosX, randPosY, randPosZ);
      }
  }
}

lcass
Member

Posts : 145
Join date : 2011-10-24
Location : england

View user profile http://www.youtube.com/user/thealcasgroup

Back to top Go down

Re: [1.8.1] Generating Ores

Post by jesshankin22 on Fri Oct 28, 2011 12:12 am

hmmm... it says it can't recognize the character "public"...

jesshankin22
Member

Posts : 47
Join date : 2011-10-24

View user profile

Back to top Go down

Re: [1.8.1] Generating Ores

Post by lcass on Fri Oct 28, 2011 12:13 am

WOW

lcass
Member

Posts : 145
Join date : 2011-10-24
Location : england

View user profile http://www.youtube.com/user/thealcasgroup

Back to top Go down

Re: [1.8.1] Generating Ores

Post by jesshankin22 on Fri Oct 28, 2011 8:19 pm

Wow what?

jesshankin22
Member

Posts : 47
Join date : 2011-10-24

View user profile

Back to top Go down

Re: [1.8.1] Generating Ores

Post by ikke009 on Fri Oct 28, 2011 8:26 pm

wow you could probably click on the error icon in front of the line number to get a list of things you can change the word public in and click the right one, or if you click the word public itself. that is, if you are using eclipse
avatar
ikke009
Member

Posts : 65
Join date : 2011-10-24
Age : 22
Location : The netherlands

View user profile

Back to top Go down

Re: [1.8.1] Generating Ores

Post by lcass on Fri Oct 28, 2011 8:27 pm

Very Happy cant recognize character public

lcass
Member

Posts : 145
Join date : 2011-10-24
Location : england

View user profile http://www.youtube.com/user/thealcasgroup

Back to top Go down

Re: [1.8.1] Generating Ores

Post by bottz2 on Sat Oct 29, 2011 9:24 pm

it wont gen

bottz2
Member

Posts : 14
Join date : 2011-10-24

View user profile

Back to top Go down

Re: [1.8.1] Generating Ores

Post by ikke009 on Sat Oct 29, 2011 10:41 pm

bottz2 wrote:it wont gen
you might want to start by making a topic in the help section, posging your code and your problem in the right format.. right now i cant magically tell you like 'oh you have to add a ; to the end of line 7 then itll work..'
avatar
ikke009
Member

Posts : 65
Join date : 2011-10-24
Age : 22
Location : The netherlands

View user profile

Back to top Go down

Re: [1.8.1] Generating Ores

Post by jesshankin22 on Sat Oct 29, 2011 11:00 pm

Oh I know that was when I was a n00b to the site... just disregard that cause I got it all figured out, but thanks anyway.

jesshankin22
Member

Posts : 47
Join date : 2011-10-24

View user profile

Back to top Go down

Re: [1.8.1] Generating Ores

Post by thedirtyassassin on Sun Oct 30, 2011 2:24 pm

where do i put the code? what do you mean by out side of the modloader stuff?

thedirtyassassin
Member

Posts : 28
Join date : 2011-10-30
Location : In your dreams!

View user profile

Back to top Go down

Re: [1.8.1] Generating Ores

Post by ikke009 on Sun Oct 30, 2011 2:56 pm

this is the code i use for my titanium ore.
I put it in a new class file called mod_titaniumore, which is needed for every generator if you want to genereate more then 1 ore without getting crashes or getting your code unorganized.
Code:

package net.minecraft.src;
import java.util.Random;
public class mod_titaniumore extends BaseMod
{

   public void GenerateSurface(World world, Random rand, int chunkX, int chunkZ)
     {
         for(int i = 0; i < 5; i++)
         {
             int randPosX = chunkX + rand.nextInt(16);
             int randPosY = rand.nextInt(20);
             int randPosZ = chunkZ + rand.nextInt(16);
             (new WorldGenMinable(mod_jasper.titaniumore.blockID, 70)).generate(world, rand, randPosX, randPosY, randPosZ);
         }
     }
 
public String Version()
  {
      return "1.8.1";
  }
}
avatar
ikke009
Member

Posts : 65
Join date : 2011-10-24
Age : 22
Location : The netherlands

View user profile

Back to top Go down

Re: [1.8.1] Generating Ores

Post by blackhounter on Sun Oct 30, 2011 5:42 pm

rarity values are
diamond : 1
gold : 2
coal : 20

thats all i know

blackhounter
Member

Posts : 1
Join date : 2011-10-24

View user profile

Back to top Go down

Re: [1.8.1] Generating Ores

Post by thedirtyassassin on Sun Oct 30, 2011 5:44 pm

ikke009 wrote:this is the code i use for my titanium ore.
I put it in a new class file called mod_titaniumore, which is needed for every generator if you want to genereate more then 1 ore without getting crashes or getting your code unorganized.
Code:

package net.minecraft.src;
import java.util.Random;
public class mod_titaniumore extends BaseMod
{

   public void GenerateSurface(World world, Random rand, int chunkX, int chunkZ)
     {
         for(int i = 0; i < 5; i++)
         {
             int randPosX = chunkX + rand.nextInt(16);
             int randPosY = rand.nextInt(20);
             int randPosZ = chunkZ + rand.nextInt(16);
             (new WorldGenMinable(mod_jasper.titaniumore.blockID, 70)).generate(world, rand, randPosX, randPosY, randPosZ);
         }
     }
 
public String Version()
  {
      return "1.8.1";
  }
}

but where do you put the class file?

thedirtyassassin
Member

Posts : 28
Join date : 2011-10-30
Location : In your dreams!

View user profile

Back to top Go down

Re: [1.8.1] Generating Ores

Post by ikke009 on Sun Oct 30, 2011 6:07 pm

blackhounter wrote:rarity values are
diamond : 1
gold : 2
coal : 20

thats all i know
source of information please?
avatar
ikke009
Member

Posts : 65
Join date : 2011-10-24
Age : 22
Location : The netherlands

View user profile

Back to top Go down

Re: [1.8.1] Generating Ores

Post by ikke009 on Sun Oct 30, 2011 6:08 pm

thedirtyassassin wrote:
ikke009 wrote:snip

but where do you put the class file?
well in the net.minecraft.src of course
avatar
ikke009
Member

Posts : 65
Join date : 2011-10-24
Age : 22
Location : The netherlands

View user profile

Back to top Go down

Re: [1.8.1] Generating Ores

Post by groxmapper on Sun Oct 30, 2011 6:30 pm

ikke009 wrote:
thedirtyassassin wrote:
ikke009 wrote:snip

but where do you put the class file?
well in the net.minecraft.src of course

To put what he said in other words, in the .jar or in a .zip in the mods folder.

EDIT: your not talking about the .class file, your talking about the .java file! The .java file goes in "MCPDIR/src/net/minecraft/src".
avatar
groxmapper
Member

Posts : 27
Join date : 2011-10-24

View user profile

Back to top Go down

Re: [1.8.1] Generating Ores

Post by sammko on Tue Nov 01, 2011 10:12 pm

ikke009 wrote:how does the rarity work? if coal is 20, would diamond be higher or lower?
for exaple: if RARITY is 20, the worldgen will try to put the block 20 times per chunk
if its 3 it will try to place it 3 times per chunk. so diamond RARITY is lower

sammko
Member

Posts : 5
Join date : 2011-11-01

View user profile

Back to top Go down

Re: [1.8.1] Generating Ores

Post by GodSend on Tue Nov 15, 2011 5:03 am

I have one question about this, what .java files exactly would you make? Like, would you make an mod_NameHere for the actual ore, and then make like another mod_WorldGenThingy and would that make the Item you created before automatically generate into the world?

One thing that saddens me is the small amount of descriptiveness Strength puts into his tutorials Sad

GodSend
Member

Posts : 2
Join date : 2011-11-15

View user profile

Back to top Go down

Re: [1.8.1] Generating Ores

Post by jesshankin22 on Tue Nov 15, 2011 6:12 am

well you could, but you don't have to. basically what you do is put it in between the brackets

jesshankin22
Member

Posts : 47
Join date : 2011-10-24

View user profile

Back to top Go down

Re: [1.8.1] Generating Ores

Post by GodSend on Wed Nov 16, 2011 12:48 am

Wait, I just figured it out. In the .java file you make for the block you include the whole world generation thingy for that block. Well, I'm recompiling and seeing if it worked.

GodSend
Member

Posts : 2
Join date : 2011-11-15

View user profile

Back to top Go down

Re: [1.8.1] Generating Ores

Post by Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum