Jump to content

Custom Structure in Custom Biome 1.7.2


ess0523

Recommended Posts

I want to create a custom structure and add it to only spawn in my custom biome. I have my custom biome already set up, and it works, but I have no idea where to start with my structure. I have looked through the all the classes in the world.gen.structure package and try to recreate it, but it never works. So could anybody explain the structure generating system so I get it a little better and explain where to start on this structure?

Link to comment
Share on other sites

1. Create a new class which implements the IWorldGenerator

2. Create a new variable in your main class for the IWorldGenerator

3. Register your world generator in your main class

 

Here is an example:

 

Your world generator (called Test):

 

package XXX.XXXX.XXXX;

import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.biome.BiomeGenPlains;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenMinable;
import cpw.mods.fml.common.IWorldGenerator;

public class Test implements IWorldGenerator 
{ 
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) 
{
switch(world.provider.dimensionId)
{
case -1:
generateNether(world, random, chunkX * 16, chunkZ * 16);
break;
case 0:
generateSurface(world, random, chunkX * 16, chunkZ * 16);
break;
case 1:
generateEnd(world, random, chunkX * 16, chunkZ * 16);
break;
}
}

private void generateEnd(World w, Random r, int i, int j) 
{
}

private void generateSurface(World world, Random random, int i2, int k2)
{ 

int i = i2 + random.nextInt(15);
int k = k2 + random.nextInt(15);

int j = world.getHeightValue(i,k)-1;


if((random.nextInt(1000000)+1)<=100000){
boolean place = true;

if(place){
world.setBlock(i+0, j+0, k+0, Block.getBlockById(44), 3, 2);
world.setBlock(i+1, j+0, k+0, Block.getBlockById(44), 3, 2);
world.setBlock(i+2, j+0, k+0, Block.getBlockById(44), 3, 2);
world.setBlock(i+3, j+0, k+0, Block.getBlockById(44), 3, 2);
world.setBlock(i+4, j+0, k+0, Block.getBlockById(44), 3, 2);
world.setBlock(i+0, j+0, k+1, Block.getBlockById(44), 3, 2);
world.setBlock(i+1, j+0, k+1, Block.getBlockById(4), 0, 2);
world.setBlock(i+2, j+0, k+1, Block.getBlockById(4), 0, 2);
world.setBlock(i+3, j+0, k+1, Block.getBlockById(4), 0, 2);
world.setBlock(i+4, j+0, k+1, Block.getBlockById(44), 3, 2);
world.setBlock(i+0, j+0, k+2, Block.getBlockById(44), 3, 2);
world.setBlock(i+1, j+0, k+2, Block.getBlockById(4), 0, 2);
world.setBlock(i+2, j+0, k+2, Block.getBlockById(9), 0, 2);
world.setBlock(i+3, j+0, k+2, Block.getBlockById(4), 0, 2);
world.setBlock(i+4, j+0, k+2, Block.getBlockById(44), 3, 2);
world.setBlock(i+0, j+0, k+3, Block.getBlockById(44), 3, 2);
world.setBlock(i+1, j+0, k+3, Block.getBlockById(4), 0, 2);
world.setBlock(i+2, j+0, k+3, Block.getBlockById(4), 0, 2);
world.setBlock(i+3, j+0, k+3, Block.getBlockById(4), 0, 2);
world.setBlock(i+4, j+0, k+3, Block.getBlockById(44), 3, 2);
world.setBlock(i+0, j+0, k+4, Block.getBlockById(44), 3, 2);
world.setBlock(i+1, j+0, k+4, Block.getBlockById(44), 3, 2);
world.setBlock(i+2, j+0, k+4, Block.getBlockById(44), 3, 2);
world.setBlock(i+3, j+0, k+4, Block.getBlockById(44), 3, 2);
world.setBlock(i+4, j+0, k+4, Block.getBlockById(44), 3, 2);
world.setBlock(i+1, j+1, k+1, Block.getBlockById(4), 0, 2);
world.setBlock(i+3, j+1, k+1, Block.getBlockById(4), 0, 2);
world.setBlock(i+1, j+1, k+3, Block.getBlockById(4), 0, 2);
world.setBlock(i+3, j+1, k+3, Block.getBlockById(4), 0, 2);
world.setBlock(i+1, j+2, k+1, Block.getBlockById(4), 0, 2);
world.setBlock(i+3, j+2, k+1, Block.getBlockById(4), 0, 2);
world.setBlock(i+1, j+2, k+3, Block.getBlockById(4), 0, 2);
world.setBlock(i+3, j+2, k+3, Block.getBlockById(4), 0, 2);
world.setBlock(i+1, j+3, k+1, Block.getBlockById(4), 0, 2);
world.setBlock(i+3, j+3, k+1, Block.getBlockById(4), 0, 2);
world.setBlock(i+1, j+3, k+3, Block.getBlockById(4), 0, 2);
world.setBlock(i+3, j+3, k+3, Block.getBlockById(4), 0, 2);
world.setBlock(i+1, j+4, k+1, Block.getBlockById(4), 0, 2);
world.setBlock(i+2, j+4, k+1, Block.getBlockById(4), 0, 2);
world.setBlock(i+3, j+4, k+1, Block.getBlockById(4), 0, 2);
world.setBlock(i+1, j+4, k+2, Block.getBlockById(4), 0, 2);
world.setBlock(i+2, j+4, k+2, Block.getBlockById(4), 0, 2);
world.setBlock(i+3, j+4, k+2, Block.getBlockById(4), 0, 2);
world.setBlock(i+1, j+4, k+3, Block.getBlockById(4), 0, 2);
world.setBlock(i+2, j+4, k+3, Block.getBlockById(4), 0, 2);
world.setBlock(i+3, j+4, k+3, Block.getBlockById(4), 0, 2);
}}}

private void generateNether(World w, Random rand, int i, int j)
{
}

}

 

and in your main class:

 

public static IWorldGenerator test = new Test();


//and in the init:
GameRegistry.registerWorldGenerator(test, 1);

 

If you only want to generate your structure in your biome, you have to check if the current biome is yours:

 

if(world.getWorldChunkManager().getBiomeGenAt(x,y)==YOURBIOME){
     place(true);
}

 

Link to comment
Share on other sites

1. Create a new class which implements the IWorldGenerator

2. Create a new variable in your main class for the IWorldGenerator

3. Register your world generator in your main class

 

Here is an example:

 

Your world generator (called Test):

 

package XXX.XXXX.XXXX;

import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.biome.BiomeGenPlains;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenMinable;
import cpw.mods.fml.common.IWorldGenerator;

public class Test implements IWorldGenerator 
{ 
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) 
{
switch(world.provider.dimensionId)
{
case -1:
generateNether(world, random, chunkX * 16, chunkZ * 16);
break;
case 0:
generateSurface(world, random, chunkX * 16, chunkZ * 16);
break;
case 1:
generateEnd(world, random, chunkX * 16, chunkZ * 16);
break;
}
}

private void generateEnd(World w, Random r, int i, int j) 
{
}

private void generateSurface(World world, Random random, int i2, int k2)
{ 

int i = i2 + random.nextInt(15);
int k = k2 + random.nextInt(15);

int j = world.getHeightValue(i,k)-1;


if((random.nextInt(1000000)+1)<=100000){
boolean place = true;

if(place){
world.setBlock(i+0, j+0, k+0, Block.getBlockById(44), 3, 2);
world.setBlock(i+1, j+0, k+0, Block.getBlockById(44), 3, 2);
world.setBlock(i+2, j+0, k+0, Block.getBlockById(44), 3, 2);
world.setBlock(i+3, j+0, k+0, Block.getBlockById(44), 3, 2);
world.setBlock(i+4, j+0, k+0, Block.getBlockById(44), 3, 2);
world.setBlock(i+0, j+0, k+1, Block.getBlockById(44), 3, 2);
world.setBlock(i+1, j+0, k+1, Block.getBlockById(4), 0, 2);
world.setBlock(i+2, j+0, k+1, Block.getBlockById(4), 0, 2);
world.setBlock(i+3, j+0, k+1, Block.getBlockById(4), 0, 2);
world.setBlock(i+4, j+0, k+1, Block.getBlockById(44), 3, 2);
world.setBlock(i+0, j+0, k+2, Block.getBlockById(44), 3, 2);
world.setBlock(i+1, j+0, k+2, Block.getBlockById(4), 0, 2);
world.setBlock(i+2, j+0, k+2, Block.getBlockById(9), 0, 2);
world.setBlock(i+3, j+0, k+2, Block.getBlockById(4), 0, 2);
world.setBlock(i+4, j+0, k+2, Block.getBlockById(44), 3, 2);
world.setBlock(i+0, j+0, k+3, Block.getBlockById(44), 3, 2);
world.setBlock(i+1, j+0, k+3, Block.getBlockById(4), 0, 2);
world.setBlock(i+2, j+0, k+3, Block.getBlockById(4), 0, 2);
world.setBlock(i+3, j+0, k+3, Block.getBlockById(4), 0, 2);
world.setBlock(i+4, j+0, k+3, Block.getBlockById(44), 3, 2);
world.setBlock(i+0, j+0, k+4, Block.getBlockById(44), 3, 2);
world.setBlock(i+1, j+0, k+4, Block.getBlockById(44), 3, 2);
world.setBlock(i+2, j+0, k+4, Block.getBlockById(44), 3, 2);
world.setBlock(i+3, j+0, k+4, Block.getBlockById(44), 3, 2);
world.setBlock(i+4, j+0, k+4, Block.getBlockById(44), 3, 2);
world.setBlock(i+1, j+1, k+1, Block.getBlockById(4), 0, 2);
world.setBlock(i+3, j+1, k+1, Block.getBlockById(4), 0, 2);
world.setBlock(i+1, j+1, k+3, Block.getBlockById(4), 0, 2);
world.setBlock(i+3, j+1, k+3, Block.getBlockById(4), 0, 2);
world.setBlock(i+1, j+2, k+1, Block.getBlockById(4), 0, 2);
world.setBlock(i+3, j+2, k+1, Block.getBlockById(4), 0, 2);
world.setBlock(i+1, j+2, k+3, Block.getBlockById(4), 0, 2);
world.setBlock(i+3, j+2, k+3, Block.getBlockById(4), 0, 2);
world.setBlock(i+1, j+3, k+1, Block.getBlockById(4), 0, 2);
world.setBlock(i+3, j+3, k+1, Block.getBlockById(4), 0, 2);
world.setBlock(i+1, j+3, k+3, Block.getBlockById(4), 0, 2);
world.setBlock(i+3, j+3, k+3, Block.getBlockById(4), 0, 2);
world.setBlock(i+1, j+4, k+1, Block.getBlockById(4), 0, 2);
world.setBlock(i+2, j+4, k+1, Block.getBlockById(4), 0, 2);
world.setBlock(i+3, j+4, k+1, Block.getBlockById(4), 0, 2);
world.setBlock(i+1, j+4, k+2, Block.getBlockById(4), 0, 2);
world.setBlock(i+2, j+4, k+2, Block.getBlockById(4), 0, 2);
world.setBlock(i+3, j+4, k+2, Block.getBlockById(4), 0, 2);
world.setBlock(i+1, j+4, k+3, Block.getBlockById(4), 0, 2);
world.setBlock(i+2, j+4, k+3, Block.getBlockById(4), 0, 2);
world.setBlock(i+3, j+4, k+3, Block.getBlockById(4), 0, 2);
}}}

private void generateNether(World w, Random rand, int i, int j)
{
}

}

 

and in your main class:

 

public static IWorldGenerator test = new Test();


//and in the init:
GameRegistry.registerWorldGenerator(test, 1);

 

If you only want to generate your structure in your biome, you have to check if the current biome is yours:

 

if(world.getWorldChunkManager().getBiomeGenAt(x,y)==YOURBIOME){
     place(true);
}

 

Thank you! I got some different test structures to spawn! But now I want to spawn a bigger scale structure. Is there an easier way to put a structure into code than writing each line out? Is there a program or something to do it?

Link to comment
Share on other sites

I only found a program for an old minecraft version:

http://www.minecraftforum.net/topic/1336152-132-updated-metadata-support-simple-schematic-to-java-file-converter/

Just select a .schematic file and then you get the code for java - but be careful: This is NOT the right code. You have to replace all the world.setBlock lines with the new code (You can do this easily in the notepad!).

This program also splits the code into different methodes, because java cannot place more than 1600 blocks in one methode!

 

If you don't what a .schematic file is - Google is your friend!

 

PS: You can create a schematic file with MCEdit.

Link to comment
Share on other sites

I only found a program for an old minecraft version:

http://www.minecraftforum.net/topic/1336152-132-updated-metadata-support-simple-schematic-to-java-file-converter/

Just select a .schematic file and then you get the code for java - but be careful: This is NOT the right code. You have to replace all the world.setBlock lines with the new code (You can do this easily in the notepad!).

This program also splits the code into different methodes, because java cannot place more than 1600 blocks in one methode!

 

If you don't what a .schematic file is - Google is your friend!

 

PS: You can create a schematic file with MCEdit.

 

Thank You! I created a schematic file with MCEdit and was able to spawn my structure (accidently I spawned them ALL over the place!) But at least it works!

Link to comment
Share on other sites

  • 2 months 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.