Create your structure in MCEDIT and select your whole structure
Hit the export button and export it as a template
Boot up schematic converter and hit add file.
Browse to that template you just made, add it, then select it in the box.
Select the spawn conditions you would like to set and make sure your whole structure is there by using the + and - buttons on the right hand side to stelp through each layer. Hit generate and browse to the output folder in the schematic converter folder. There you will find your java file you can drag into your project in eclipse or whatever you are using to program your mod. Click on the file you just added to your project to see your code
Update your code to what I have
/*
*** MADE BY MRPONYCAPTAIN'S .SCHEMATIC TO .JAVA CONVERTING TOOL v2.0 ***
*/
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkGenerator;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenerator;
import net.minecraftforge.fml.common.IWorldGenerator;
public class NewWorld_20180130132930 extends WorldGenerator implements IWorldGenerator
{
protected Block[] getValidSpawnBlocks() {
return new Block[] {
Blocks.DIRT
};
}
public boolean locationIsValidSpawn(World world, int i, int j, int k){
int distanceToAir = 0;
BlockPos pos = new BlockPos(i, j, k);
Block check = world.getBlockState(pos).getBlock();
while (check != Blocks.AIR){
if (distanceToAir > 3){
return false;
}
distanceToAir++;
check = world.getBlockState(pos.up(distanceToAir)).getBlock();
}
j += distanceToAir - 1;
Block block = world.getBlockState(pos).getBlock();
Block blockAbove = world.getBlockState(pos.up()).getBlock();
Block blockBelow = world.getBlockState(pos.down()).getBlock();
for (Block x : getValidSpawnBlocks()){
if (blockAbove != Blocks.AIR){
return false;
}
if (block == x){
return true;
}else if (block == Blocks.SNOW && blockBelow == x){
return true;
}
}
return false;
}
public NewWorld_20180130132930() { }
public void setBlock(World world, int x, int y, int z, Block block, int metadata)
{
IBlockState blockst = block.getBlockState().getBaseState();
BlockPos pos = new BlockPos(x, y, z);
Block b1 = world.getBlockState(pos).getBlock();
if(b1.isAir(blockst, world, pos) || b1.isLeaves(blockst, world, pos))
{
world.setBlockState(pos, blockst, metadata);
}
}
public boolean generate(World world, Random rand, int i, int j, int k) {
//check that each corner is one of the valid spawn blocks
for(int q = 0; q <= 4; q++) {
for(int w = 0; w <= 3; w++) {
for(int e = 0; e <= 4; e++) {
if(!locationIsValidSpawn(world, i + q, j + w, k + e))
{
return false;
}
e++;
}
w++;
}
q++;
}
k = k - 10;
i = i - 10;
this.setBlock(world, i + 0, j + 0, k + 0, Blocks.PLANKS, 0);
this.setBlock(world, i + 0, j + 0, k + 1, Blocks.PLANKS, 0);
this.setBlock(world, i + 0, j + 0, k + 2, Blocks.PLANKS, 0);
this.setBlock(world, i + 0, j + 0, k + 3, Blocks.PLANKS, 0);
this.setBlock(world, i + 0, j + 0, k + 4, Blocks.PLANKS, 0);
this.setBlock(world, i + 0, j + 1, k + 0, Blocks.PLANKS, 0);
this.setBlock(world, i + 0, j + 1, k + 1, Blocks.GLASS, 0);
this.setBlock(world, i + 0, j + 1, k + 2, Blocks.GLASS, 0);
this.setBlock(world, i + 0, j + 1, k + 3, Blocks.GLASS, 0);
this.setBlock(world, i + 0, j + 1, k + 4, Blocks.PLANKS, 0);
this.setBlock(world, i + 0, j + 2, k + 0, Blocks.PLANKS, 0);
this.setBlock(world, i + 0, j + 2, k + 1, Blocks.PLANKS, 0);
this.setBlock(world, i + 0, j + 2, k + 2, Blocks.PLANKS, 0);
this.setBlock(world, i + 0, j + 2, k + 3, Blocks.PLANKS, 0);
this.setBlock(world, i + 0, j + 2, k + 4, Blocks.PLANKS, 0);
this.setBlock(world, i + 1, j + 0, k + 0, Blocks.PLANKS, 0);
this.setBlock(world, i + 1, j + 0, k + 4, Blocks.PLANKS, 0);
this.setBlock(world, i + 1, j + 1, k + 0, Blocks.PLANKS, 0);
this.setBlock(world, i + 1, j + 1, k + 4, Blocks.PLANKS, 0);
this.setBlock(world, i + 1, j + 2, k + 0, Blocks.PLANKS, 0);
this.setBlock(world, i + 1, j + 2, k + 1, Blocks.PLANKS, 0);
this.setBlock(world, i + 1, j + 2, k + 2, Blocks.PLANKS, 0);
this.setBlock(world, i + 1, j + 2, k + 3, Blocks.PLANKS, 0);
this.setBlock(world, i + 1, j + 2, k + 4, Blocks.PLANKS, 0);
this.setBlock(world, i + 1, j + 3, k + 1, Blocks.PLANKS, 0);
this.setBlock(world, i + 1, j + 3, k + 2, Blocks.PLANKS, 0);
this.setBlock(world, i + 1, j + 3, k + 3, Blocks.PLANKS, 0);
this.setBlock(world, i + 2, j + 0, k + 4, Blocks.PLANKS, 0);
this.setBlock(world, i + 2, j + 1, k + 4, Blocks.PLANKS, 0);
this.setBlock(world, i + 2, j + 2, k + 0, Blocks.PLANKS, 0);
this.setBlock(world, i + 2, j + 2, k + 1, Blocks.PLANKS, 0);
this.setBlock(world, i + 2, j + 2, k + 2, Blocks.PLANKS, 0);
this.setBlock(world, i + 2, j + 2, k + 3, Blocks.PLANKS, 0);
this.setBlock(world, i + 2, j + 2, k + 4, Blocks.PLANKS, 0);
this.setBlock(world, i + 2, j + 3, k + 1, Blocks.PLANKS, 0);
this.setBlock(world, i + 2, j + 3, k + 2, Blocks.PLANKS, 0);
this.setBlock(world, i + 2, j + 3, k + 3, Blocks.PLANKS, 0);
this.setBlock(world, i + 3, j + 0, k + 0, Blocks.PLANKS, 0);
this.setBlock(world, i + 3, j + 0, k + 4, Blocks.PLANKS, 0);
this.setBlock(world, i + 3, j + 1, k + 0, Blocks.PLANKS, 0);
this.setBlock(world, i + 3, j + 1, k + 4, Blocks.PLANKS, 0);
this.setBlock(world, i + 3, j + 2, k + 0, Blocks.PLANKS, 0);
this.setBlock(world, i + 3, j + 2, k + 1, Blocks.PLANKS, 0);
this.setBlock(world, i + 3, j + 2, k + 2, Blocks.PLANKS, 0);
this.setBlock(world, i + 3, j + 2, k + 3, Blocks.PLANKS, 0);
this.setBlock(world, i + 3, j + 2, k + 4, Blocks.PLANKS, 0);
this.setBlock(world, i + 3, j + 3, k + 1, Blocks.PLANKS, 0);
this.setBlock(world, i + 3, j + 3, k + 2, Blocks.PLANKS, 0);
this.setBlock(world, i + 3, j + 3, k + 3, Blocks.PLANKS, 0);
this.setBlock(world, i + 4, j + 0, k + 0, Blocks.PLANKS, 0);
this.setBlock(world, i + 4, j + 0, k + 1, Blocks.PLANKS, 0);
this.setBlock(world, i + 4, j + 0, k + 2, Blocks.PLANKS, 0);
this.setBlock(world, i + 4, j + 0, k + 3, Blocks.PLANKS, 0);
this.setBlock(world, i + 4, j + 0, k + 4, Blocks.PLANKS, 0);
this.setBlock(world, i + 4, j + 1, k + 0, Blocks.PLANKS, 0);
this.setBlock(world, i + 4, j + 1, k + 1, Blocks.GLASS, 0);
this.setBlock(world, i + 4, j + 1, k + 2, Blocks.GLASS, 0);
this.setBlock(world, i + 4, j + 1, k + 3, Blocks.GLASS, 0);
this.setBlock(world, i + 4, j + 1, k + 4, Blocks.PLANKS, 0);
this.setBlock(world, i + 4, j + 2, k + 0, Blocks.PLANKS, 0);
this.setBlock(world, i + 4, j + 2, k + 1, Blocks.PLANKS, 0);
this.setBlock(world, i + 4, j + 2, k + 2, Blocks.PLANKS, 0);
this.setBlock(world, i + 4, j + 2, k + 3, Blocks.PLANKS, 0);
this.setBlock(world, i + 4, j + 2, k + 4, Blocks.PLANKS, 0);
return true;
}
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator,
IChunkProvider chunkProvider) {
// TODO Auto-generated method stub
}
@Override
public boolean generate(World worldIn, Random rand, BlockPos position) {
// TODO Auto-generated method stub
return false;
}
}
After that go to your WorldGen file. If you have not created a WorldGen File look up some tutorials on how to make an ore spawn in your world
Add the following code to your WorldGen:
int f = random.nextInt(100) + 1;
if (f == 34) {
for (int i = 0; i < 1; i++) {
System.out.println("Generating ");
int x = chunkX * 16 + random.nextInt(16);
int y = random.nextInt(200) + 75;
int z = chunkZ * 16 + random.nextInt(16);
new BasicIsland().generate(world, random, x, y, z);
}
}
The f randomizer prevented my structure from spawning too much. You can remove the if and the f = random.nextInt(100) + 1 to make it spawn more. If it is still not spawning enough, adjust the i < 1 to a higher number like i < 20.
Hope this helps!
PS I don't check the forums often so if I don't respond quick enough, just know I have a life.
Today after banging my head on the table for 5 hours. I finally got a working structure to spawn in the overworld. Thought I would help some peeps out
MCEDIT and the Schematic Converter are recquired
(I used the first version because the second version wouldn't work on my pc)
MCEDIT: http://www.mcedit.net/downloads.html
(The schematic converter was made for 1.7.2 but we will be updating the code. Props to MrPony Captain for this tool!)
Schematic Converter: http://www.minecraftforum.net/forums/mapping-and-modding-java-edition/minecraft-tools/2216346-1-7-2-schematic-to-java-converter
Create your structure in MCEDIT and select your whole structure
Hit the export button and export it as a template
Boot up schematic converter and hit add file.
Browse to that template you just made, add it, then select it in the box.
Select the spawn conditions you would like to set and make sure your whole structure is there by using the + and - buttons on the right hand side to stelp through each layer. Hit generate and browse to the output folder in the schematic converter folder. There you will find your java file you can drag into your project in eclipse or whatever you are using to program your mod. Click on the file you just added to your project to see your code
Update your code to what I have
/* *** MADE BY MRPONYCAPTAIN'S .SCHEMATIC TO .JAVA CONVERTING TOOL v2.0 *** */ import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.chunk.IChunkGenerator; import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.gen.feature.WorldGenerator; import net.minecraftforge.fml.common.IWorldGenerator; public class NewWorld_20180130132930 extends WorldGenerator implements IWorldGenerator { protected Block[] getValidSpawnBlocks() { return new Block[] { Blocks.DIRT }; } public boolean locationIsValidSpawn(World world, int i, int j, int k){ int distanceToAir = 0; BlockPos pos = new BlockPos(i, j, k); Block check = world.getBlockState(pos).getBlock(); while (check != Blocks.AIR){ if (distanceToAir > 3){ return false; } distanceToAir++; check = world.getBlockState(pos.up(distanceToAir)).getBlock(); } j += distanceToAir - 1; Block block = world.getBlockState(pos).getBlock(); Block blockAbove = world.getBlockState(pos.up()).getBlock(); Block blockBelow = world.getBlockState(pos.down()).getBlock(); for (Block x : getValidSpawnBlocks()){ if (blockAbove != Blocks.AIR){ return false; } if (block == x){ return true; }else if (block == Blocks.SNOW && blockBelow == x){ return true; } } return false; } public NewWorld_20180130132930() { } public void setBlock(World world, int x, int y, int z, Block block, int metadata) { IBlockState blockst = block.getBlockState().getBaseState(); BlockPos pos = new BlockPos(x, y, z); Block b1 = world.getBlockState(pos).getBlock(); if(b1.isAir(blockst, world, pos) || b1.isLeaves(blockst, world, pos)) { world.setBlockState(pos, blockst, metadata); } } public boolean generate(World world, Random rand, int i, int j, int k) { //check that each corner is one of the valid spawn blocks for(int q = 0; q <= 4; q++) { for(int w = 0; w <= 3; w++) { for(int e = 0; e <= 4; e++) { if(!locationIsValidSpawn(world, i + q, j + w, k + e)) { return false; } e++; } w++; } q++; } k = k - 10; i = i - 10; this.setBlock(world, i + 0, j + 0, k + 0, Blocks.PLANKS, 0); this.setBlock(world, i + 0, j + 0, k + 1, Blocks.PLANKS, 0); this.setBlock(world, i + 0, j + 0, k + 2, Blocks.PLANKS, 0); this.setBlock(world, i + 0, j + 0, k + 3, Blocks.PLANKS, 0); this.setBlock(world, i + 0, j + 0, k + 4, Blocks.PLANKS, 0); this.setBlock(world, i + 0, j + 1, k + 0, Blocks.PLANKS, 0); this.setBlock(world, i + 0, j + 1, k + 1, Blocks.GLASS, 0); this.setBlock(world, i + 0, j + 1, k + 2, Blocks.GLASS, 0); this.setBlock(world, i + 0, j + 1, k + 3, Blocks.GLASS, 0); this.setBlock(world, i + 0, j + 1, k + 4, Blocks.PLANKS, 0); this.setBlock(world, i + 0, j + 2, k + 0, Blocks.PLANKS, 0); this.setBlock(world, i + 0, j + 2, k + 1, Blocks.PLANKS, 0); this.setBlock(world, i + 0, j + 2, k + 2, Blocks.PLANKS, 0); this.setBlock(world, i + 0, j + 2, k + 3, Blocks.PLANKS, 0); this.setBlock(world, i + 0, j + 2, k + 4, Blocks.PLANKS, 0); this.setBlock(world, i + 1, j + 0, k + 0, Blocks.PLANKS, 0); this.setBlock(world, i + 1, j + 0, k + 4, Blocks.PLANKS, 0); this.setBlock(world, i + 1, j + 1, k + 0, Blocks.PLANKS, 0); this.setBlock(world, i + 1, j + 1, k + 4, Blocks.PLANKS, 0); this.setBlock(world, i + 1, j + 2, k + 0, Blocks.PLANKS, 0); this.setBlock(world, i + 1, j + 2, k + 1, Blocks.PLANKS, 0); this.setBlock(world, i + 1, j + 2, k + 2, Blocks.PLANKS, 0); this.setBlock(world, i + 1, j + 2, k + 3, Blocks.PLANKS, 0); this.setBlock(world, i + 1, j + 2, k + 4, Blocks.PLANKS, 0); this.setBlock(world, i + 1, j + 3, k + 1, Blocks.PLANKS, 0); this.setBlock(world, i + 1, j + 3, k + 2, Blocks.PLANKS, 0); this.setBlock(world, i + 1, j + 3, k + 3, Blocks.PLANKS, 0); this.setBlock(world, i + 2, j + 0, k + 4, Blocks.PLANKS, 0); this.setBlock(world, i + 2, j + 1, k + 4, Blocks.PLANKS, 0); this.setBlock(world, i + 2, j + 2, k + 0, Blocks.PLANKS, 0); this.setBlock(world, i + 2, j + 2, k + 1, Blocks.PLANKS, 0); this.setBlock(world, i + 2, j + 2, k + 2, Blocks.PLANKS, 0); this.setBlock(world, i + 2, j + 2, k + 3, Blocks.PLANKS, 0); this.setBlock(world, i + 2, j + 2, k + 4, Blocks.PLANKS, 0); this.setBlock(world, i + 2, j + 3, k + 1, Blocks.PLANKS, 0); this.setBlock(world, i + 2, j + 3, k + 2, Blocks.PLANKS, 0); this.setBlock(world, i + 2, j + 3, k + 3, Blocks.PLANKS, 0); this.setBlock(world, i + 3, j + 0, k + 0, Blocks.PLANKS, 0); this.setBlock(world, i + 3, j + 0, k + 4, Blocks.PLANKS, 0); this.setBlock(world, i + 3, j + 1, k + 0, Blocks.PLANKS, 0); this.setBlock(world, i + 3, j + 1, k + 4, Blocks.PLANKS, 0); this.setBlock(world, i + 3, j + 2, k + 0, Blocks.PLANKS, 0); this.setBlock(world, i + 3, j + 2, k + 1, Blocks.PLANKS, 0); this.setBlock(world, i + 3, j + 2, k + 2, Blocks.PLANKS, 0); this.setBlock(world, i + 3, j + 2, k + 3, Blocks.PLANKS, 0); this.setBlock(world, i + 3, j + 2, k + 4, Blocks.PLANKS, 0); this.setBlock(world, i + 3, j + 3, k + 1, Blocks.PLANKS, 0); this.setBlock(world, i + 3, j + 3, k + 2, Blocks.PLANKS, 0); this.setBlock(world, i + 3, j + 3, k + 3, Blocks.PLANKS, 0); this.setBlock(world, i + 4, j + 0, k + 0, Blocks.PLANKS, 0); this.setBlock(world, i + 4, j + 0, k + 1, Blocks.PLANKS, 0); this.setBlock(world, i + 4, j + 0, k + 2, Blocks.PLANKS, 0); this.setBlock(world, i + 4, j + 0, k + 3, Blocks.PLANKS, 0); this.setBlock(world, i + 4, j + 0, k + 4, Blocks.PLANKS, 0); this.setBlock(world, i + 4, j + 1, k + 0, Blocks.PLANKS, 0); this.setBlock(world, i + 4, j + 1, k + 1, Blocks.GLASS, 0); this.setBlock(world, i + 4, j + 1, k + 2, Blocks.GLASS, 0); this.setBlock(world, i + 4, j + 1, k + 3, Blocks.GLASS, 0); this.setBlock(world, i + 4, j + 1, k + 4, Blocks.PLANKS, 0); this.setBlock(world, i + 4, j + 2, k + 0, Blocks.PLANKS, 0); this.setBlock(world, i + 4, j + 2, k + 1, Blocks.PLANKS, 0); this.setBlock(world, i + 4, j + 2, k + 2, Blocks.PLANKS, 0); this.setBlock(world, i + 4, j + 2, k + 3, Blocks.PLANKS, 0); this.setBlock(world, i + 4, j + 2, k + 4, Blocks.PLANKS, 0); return true; } @Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) { // TODO Auto-generated method stub } @Override public boolean generate(World worldIn, Random rand, BlockPos position) { // TODO Auto-generated method stub return false; } }After that go to your WorldGen file. If you have not created a WorldGen File look up some tutorials on how to make an ore spawn in your world
Add the following code to your WorldGen:
int f = random.nextInt(100) + 1; if (f == 34) { for (int i = 0; i < 1; i++) { System.out.println("Generating "); int x = chunkX * 16 + random.nextInt(16); int y = random.nextInt(200) + 75; int z = chunkZ * 16 + random.nextInt(16); new BasicIsland().generate(world, random, x, y, z); } }The f randomizer prevented my structure from spawning too much. You can remove the if and the f = random.nextInt(100) + 1 to make it spawn more. If it is still not spawning enough, adjust the i < 1 to a higher number like i < 20.
Hope this helps!
PS I don't check the forums often so if I don't respond quick enough, just know I have a life.
How different is structure gen in 1.12?