Jump to content

Structure Gen not Working


nightscout01

Recommended Posts

Hi everyone, I am trying to make a mod that allows more structures to generate in the world, however, my code does not seem to be working. Can anyone tell me what's wrong with it?

 

My main mod class file



package net.morestructures.mod;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.morestructures.mod.blocks.BuildersBlock;
import net.morestructures.mod.blocks.OreBlock;
import net.morestructures.mod.items.MCItems;
import net.morestructures.mod.worldgen.MorestructureWorldGen;
import net.morestructures.mod.worldgen.Test;
import cpw.mods.fml.common.IWorldGenerator;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;



@Mod(modid = Morestructures.modid, version = Morestructures.version)
public class Morestructures {
public static final String modid = "Morestructures";
public static final String version = "Alpha 0.1";

MorestructureWorldGen eventWorldGen = new MorestructureWorldGen();



public static CreativeTabs morestructuresTab;

public static Item itemBuildersIngot;
public static Item itemStructureIngot;
public static Item itemUnusedIngot;
public static IWorldGenerator test = new Test();



public static Block oreBuildersOre;
public static Block oreStructureOre;
public static Block oreUnusedOre;

public static Block blockBuildersBlock;
   
@EventHandler
public void PreInit(FMLPreInitializationEvent preEvent){

morestructuresTab = new CreativeTabs("Morestructures") {
@SideOnly(Side.CLIENT)
public Item getTabIconItem() {
return Item.getItemFromBlock(Morestructures.oreBuildersOre);
}
};

itemBuildersIngot = new MCItems().setUnlocalizedName("BuildersIngot");
GameRegistry.registerItem(itemBuildersIngot, "Builders Ingot");

itemStructureIngot = new MCItems().setUnlocalizedName("StructureIngot");
GameRegistry.registerItem(itemStructureIngot, "Structure Ingot");

itemUnusedIngot = new MCItems().setUnlocalizedName("UnusedIngot");
GameRegistry.registerItem(itemUnusedIngot, "UnusedIngot");

oreBuildersOre = new OreBlock(Material.rock).setBlockName("BuildersOre");
GameRegistry.registerBlock(oreBuildersOre, "BuildersOre");

oreStructureOre = new OreBlock(Material.rock).setBlockName("StructureOre");
GameRegistry.registerBlock(oreStructureOre, "StructureOre");

oreUnusedOre = new OreBlock(Material.rock).setBlockName("UnusedOre");
GameRegistry.registerBlock(oreUnusedOre, "UnusedOre");

blockBuildersBlock = new BuildersBlock(Material.iron).setBlockName("BuildersBlock");
GameRegistry.registerBlock(blockBuildersBlock, "BuildersBlock");

//Spawn
GameRegistry.registerWorldGenerator(eventWorldGen, 0);
    }

@EventHandler
public void Init(FMLInitializationEvent event){

//Recipes
GameRegistry.addRecipe(new ItemStack(blockBuildersBlock), new Object[]{"CCC", "CCC", "CCC", 'C', itemBuildersIngot});





//Smelting
GameRegistry.addSmelting(oreBuildersOre, new ItemStack(itemBuildersIngot), 0);
GameRegistry.addSmelting(oreStructureOre, new ItemStack(itemStructureIngot), 0);
GameRegistry.addSmelting(oreUnusedOre, new ItemStack(itemUnusedIngot), 0);

GameRegistry.registerWorldGenerator(test, 1);

}

@EventHandler
public void PostInit(FMLPostInitializationEvent postEvent){
}


}


[/Code]

 

My Test world Gen file:

 

[Code]


package net.morestructures.mod.worldgen;

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(world.getWorldChunkManager().getBiomeGenAt(i,j)==BiomeGenBase.plains){{
place(true);

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 place(boolean b) {


}

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

}

[/Code]

 

Thanks for your help, nightscout01

 

 

Link to comment
Share on other sites

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.