Jump to content

Free to use world generation files [list]


Dus998

Recommended Posts

here are some world generation files that I wrote to generate blocks exactly where I wanted them

I reformatted them to be as generic as they can be so, Enjoy and use as you wish!

 

first one is called WorldGenMinableNearBlock

 

to use do (new WorldGenMinableNearBlock( blockid to spawn, metadata for that block, the number of blocks, and the block it will spawn near)

 

 

 


import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator;

public class WorldGenMinableNearBlock extends WorldGenerator
{
    /** The block ID of the ore to be placed using this generator. */
    private int minableBlockId;
    
    //metadata for spawning
    private int metadata;
    
    /** The number of blocks to generate. */
    private int numberOfBlocks;
    
    //block to spawn near, essentially next to
    private int nearBlock;
    
    public WorldGenMinableNearBlock(int par1, int par2, int par3, int near)
    {
        minableBlockId = par1;
        metadata = par2;
        numberOfBlocks = par3;
        nearBlock = near;
    }

    public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5)
    {
        float f = par2Random.nextFloat() * (float)Math.PI;
        double d = (float)(par3 +  + (MathHelper.sin(f) * (float)numberOfBlocks) / 8F;
        double d1 = (float)(par3 +  - (MathHelper.sin(f) * (float)numberOfBlocks) / 8F;
        double d2 = (float)(par5 +  + (MathHelper.cos(f) * (float)numberOfBlocks) / 8F;
        double d3 = (float)(par5 +  - (MathHelper.cos(f) * (float)numberOfBlocks) / 8F;
        double d4 = (par4 + par2Random.nextInt(3)) - 2;
        double d5 = (par4 + par2Random.nextInt(3)) - 2;

        for (int i = 0; i <= numberOfBlocks; i++)
        {
            double d6 = d + ((d1 - d) * (double)i) / (double)numberOfBlocks;
            double d7 = d4 + ((d5 - d4) * (double)i) / (double)numberOfBlocks;
            double d8 = d2 + ((d3 - d2) * (double)i) / (double)numberOfBlocks;
            double d9 = (par2Random.nextDouble() * (double)numberOfBlocks) / 16D;
            double d10 = (double)(MathHelper.sin(((float)i * (float)Math.PI) / (float)numberOfBlocks) + 1.0F) * d9 + 1.0D;
            double d11 = (double)(MathHelper.sin(((float)i * (float)Math.PI) / (float)numberOfBlocks) + 1.0F) * d9 + 1.0D;
            int j = MathHelper.floor_double(d6 - d10 / 2D);
            int k = MathHelper.floor_double(d7 - d11 / 2D);
            int l = MathHelper.floor_double(d8 - d10 / 2D);
            int i1 = MathHelper.floor_double(d6 + d10 / 2D);
            int j1 = MathHelper.floor_double(d7 + d11 / 2D);
            int k1 = MathHelper.floor_double(d8 + d10 / 2D);

            for (int l1 = j; l1 <= i1; l1++)
            {
                double d12 = (((double)l1 + 0.5D) - d6) / (d10 / 2D);

                if (d12 * d12 >= 1.0D)
                {
                    continue;
                }

                for (int i2 = k; i2 <= j1; i2++)
                {
                    double d13 = (((double)i2 + 0.5D) - d7) / (d11 / 2D);

                    if (d12 * d12 + d13 * d13 >= 1.0D)
                    {
                        continue;
                    }

                    for (int j2 = l; j2 <= k1; j2++)
                    {
                        double d14 = (((double)j2 + 0.5D) - d8) / (d10 / 2D);

                        if (d12 * d12 + d13 * d13 + d14 * d14 < 1.0D && par1World.getBlockId(l1, i2, j2) == Block.stone.blockID && ((par1World.getBlockId(l1, i2-1, j2) == nearBlock ) || (par1World.getBlockId(l1, i2+1, j2) == nearBlock ) || (par1World.getBlockId(l1, i2, j2+1) == nearBlock )|| (par1World.getBlockId(l1, i2, j2-1) == nearBlock )|| (par1World.getBlockId(l1-1, i2, j2) == nearBlock ) || (par1World.getBlockId(l1+1, i2, j2) == nearBlock ) || ((par1World.getBlockId(l1, i2+1, j2) == this.minableBlockId) && (par1World.getBlockMetadata(l1, i2+1, j2) == this.metadata)) || ((par1World.getBlockId(l1, i2-1, j2) == this.minableBlockId) && (par1World.getBlockMetadata(l1, i2-1, j2) == this.metadata)) || ((par1World.getBlockId(l1-1, i2, j2) == this.minableBlockId) && (par1World.getBlockMetadata(l1-1, i2, j2) == this.metadata)) || ((par1World.getBlockId(l1+1, i2, j2) == this.minableBlockId) && (par1World.getBlockMetadata(l1+1, i2, j2) == this.metadata)) || ((par1World.getBlockId(l1, i2, j2+1) == this.minableBlockId) && (par1World.getBlockMetadata(l1, i2, j2+1) == this.metadata)) || ((par1World.getBlockId(l1, i2, j2-1) == this.minableBlockId) && (par1World.getBlockMetadata(l1, i2, j2-1) == this.metadata)))) 
                        {
                        	par1World.setBlockAndMetadata(l1, i2, j2, minableBlockId, metadata);
                        	continue;
                        }
                    }
                }
            }
        }

        return true;
    }
}

 

 

 

the next one is so that ores will spawn in the nether and this must be ran in the generateNether in a properly formatted world generation file

 

to run do (new WorldGenMinableNether( Block Id, The metadata for that block, the number of blocks in vein)

 

 

 


import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator;

public class WorldGenMinableNether extends WorldGenerator
{
    /** The block ID of the ore to be placed using this generator. */
    private int minableBlockId;

    private int metadata;
    
    /** The number of blocks to generate. */
    private int numberOfBlocks;

    public WorldGenMinableNether(int par1, int par2, int par3)
    {
        minableBlockId = par1;
        metadata = par2;
        numberOfBlocks = par3;
    }

    public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5)
    {
        float f = par2Random.nextFloat() * (float)Math.PI;
        double d = (float)(par3 +  + (MathHelper.sin(f) * (float)numberOfBlocks) / 8F;
        double d1 = (float)(par3 +  - (MathHelper.sin(f) * (float)numberOfBlocks) / 8F;
        double d2 = (float)(par5 +  + (MathHelper.cos(f) * (float)numberOfBlocks) / 8F;
        double d3 = (float)(par5 +  - (MathHelper.cos(f) * (float)numberOfBlocks) / 8F;
        double d4 = (par4 + par2Random.nextInt(3)) - 2;
        double d5 = (par4 + par2Random.nextInt(3)) - 2;

        for (int i = 0; i <= numberOfBlocks; i++)
        {
            double d6 = d + ((d1 - d) * (double)i) / (double)numberOfBlocks;
            double d7 = d4 + ((d5 - d4) * (double)i) / (double)numberOfBlocks;
            double d8 = d2 + ((d3 - d2) * (double)i) / (double)numberOfBlocks;
            double d9 = (par2Random.nextDouble() * (double)numberOfBlocks) / 16D;
            double d10 = (double)(MathHelper.sin(((float)i * (float)Math.PI) / (float)numberOfBlocks) + 1.0F) * d9 + 1.0D;
            double d11 = (double)(MathHelper.sin(((float)i * (float)Math.PI) / (float)numberOfBlocks) + 1.0F) * d9 + 1.0D;
            int j = MathHelper.floor_double(d6 - d10 / 2D);
            int k = MathHelper.floor_double(d7 - d11 / 2D);
            int l = MathHelper.floor_double(d8 - d10 / 2D);
            int i1 = MathHelper.floor_double(d6 + d10 / 2D);
            int j1 = MathHelper.floor_double(d7 + d11 / 2D);
            int k1 = MathHelper.floor_double(d8 + d10 / 2D);

            for (int l1 = j; l1 <= i1; l1++)
            {
                double d12 = (((double)l1 + 0.5D) - d6) / (d10 / 2D);

                if (d12 * d12 >= 1.0D)
                {
                    continue;
                }

                for (int i2 = k; i2 <= j1; i2++)
                {
                    double d13 = (((double)i2 + 0.5D) - d7) / (d11 / 2D);

                    if (d12 * d12 + d13 * d13 >= 1.0D)
                    {
                        continue;
                    }

                    for (int j2 = l; j2 <= k1; j2++)
                    {
                        double d14 = (((double)j2 + 0.5D) - d8) / (d10 / 2D);

                        if (d12 * d12 + d13 * d13 + d14 * d14 < 1.0D && par1World.getBlockId(l1, i2, j2) == Block.netherrack.blockID)
                        {
                            par1World.setBlockAndMetadata(l1, i2, j2, minableBlockId, metadata);
                        }
                    }
                }
            }
        }

        return true;
    }
}

 

 

 

FBalazs's generation API

http://www.minecraftforum.net/topic/1608655-fbalazss-modding-api/

 

If you want some generation code done for you I'll gladly do it!

 

funny thing is that i have no idea how to make a tile entity but this is a breeze for me. lol.

 

if you know of a good tile entity tutorial, video if possible, please point me toward it

Link to comment
Share on other sites

I made a modding API that has nether and end generation included. See the link below.

http://www.minecraftforum.net/topic/1608655-fbalazss-modding-api/

 

My mods with my API

http://www.minecraftforum.net/topic/1609828-fbalazss-mods/

 

But I want to make a rotating block with a rotating box and a static box.

Anybody can help me how to render this in my block rendering handler?

Sorry for my bad English!

FBalazs

Link to comment
Share on other sites

FBalazs I made this a list and added your api to it

 

Also to the person 2 posts above this, i'm afraid that this can't be done with my current level of expertise, in other words i havn't learned how to read from schematic files yet

however i might do this after i learn that because i have been wanting to use something like that for some time now

Link to comment
Share on other sites

  • 3 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.