HelpNation Tutorials

Would you like to react to this message? Create an account in a few clicks or log in to continue.
HelpNation Tutorials

Learn how to mod, make, read, or just review modding tutorials and mods!


    [Creating Mods][ModLoader]Basic WorldGen Of A Block! [11-17-11]

    Or1g1n_Of_Death
    Or1g1n_Of_Death
    Forum Founder
    Forum Founder


    Posts : 24
    Join date : 2011-11-05
    Location : My Computer

    [Creating Mods][ModLoader]Basic WorldGen Of A Block! [11-17-11] Empty [Creating Mods][ModLoader]Basic WorldGen Of A Block! [11-17-11]

    Post  Or1g1n_Of_Death Thu Nov 17, 2011 10:48 pm

    Modding Disclaimer:

    I, Or1g1n_Of_Death, do not take any responsibility for anything that might happen to your computer or any device you use while making code that may be unwanted. Anything saying I will be sued, etc. Will be deleted and you will be told to review this section.

    Just in case you didn't exactly get what I first said...

    Or1g1n_Of_Death is not responsible for anything that happens to your device you use to mod with, that you may not want. Thank you, have a nice day.

    Signed,
    ~Or1g1n; The King king


    Back To Modding!

    Today, I'm going to be showing you how to make a block simply generate into the Minecraft World! This is quite easy, as all you have to do is add it to your Blocks file. Well, this should be quite easy to understand, especially if you've come this far in your modding experience. Well, Here is the code for a basic WorldGen:

    Code:

    package net.minecraft.src;

    import java.util.Random;

    public class mod_SpeedStone extends BaseMod
    {
      public static Block SpeedStone = new SpeedStone(195, 0).setHardness(9.0F).setResistance(45.0F).setStepSound(SoundStoneFootstep).setBlockName("SpeedStone");
     
      public String Version()
      {
          return "1.8.1";
      }
     
      public mod_SpeedStone()
      {
          ModLoader.RegisterBlock(SpeedStone);
          CBronzeOre.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/YourFolder/SpeedStone.png");
          ModLoader.AddName(SpeedStone, "SpeedStone");
       
      }
      public void GenerateSurface(World world, Random rand, int chunkX, int chunkZ)
      {
          for(int i = 0; i <BLOCK'S_RARITY; i++)
          {
              int randPosX = chunkX + rand.nextInt(16);
              int randPosY = rand.nextInt(HEIGHT ABOVE BEDROCK );
              int randPosZ = chunkZ + rand.nextInt(16);
              (new WorldGenMinable(mod_SpeedStone.SpeedStone.blockID, SIZE OF VEIN)).generate(world, rand, randPosX, randPosY, randPosZ);
          }
      }
    }

    Well, pretty much in that code, "BLOCK'S_RARITY" would be replaced with how rare you want this block to occur. Pretty much, the higher the number, the more often it occurs. Just for something to lean on, Coal's rarity is 20. And, I'm quite sure Diamond is 2. And, quite obviously "HEIGHT ABOVE BEDROCK" Is how high it is above Bedrock. The number you put, is how many layers down it is. For instance, Diamond is in layer 10. Now, "SIZE OF VEIN" means how much of the block you want there to be in one bundle. Pretty much, the larger the number the larger the bundle. As you may have noticed, the properties are also in there, well yeah, thta's how it's done. You put the properties in one area, and the ModLoader things in another, then in another bracketed area, the WorldGen settings. And, guess what? You just made a WorldGen file. Congrats, Bro! Also, for my mod I'm making another furnace block. If I can get it to work, I will most definitely post a tutorial!

    ~Or1g1n; The King king

      Current date/time is Tue May 14, 2024 1:24 am