Jump to content

unable to load blocks from elsewhere in the mod for custom structure generation


dylbet121

Recommended Posts

Hello there

 

recently I have wanted to include a medditeranean village as part of my mod,

To make this I need to include blocks from my mod but when I reference them like so

 

public boolean generate(World world, Random rand, int i, int j, int k)

{

world.setBlockWithNotify(i, j, k, Block.blockDiamond.blockID);

world.setBlockWithNotify(i + 1, j, k, mod_medmod.BlockTileBlock.blockID);

 

return true;

 

}

 

the error is under mod_medmod.BlockTileBlock.blockID);

the only suggestion from eclipse is to make blockID static

this is obviously not the solution

here is the rest of my code if it helps

this is in the same package as the rest of my mod

 

--------------------------------------------------------------------------------

 

package mod_medmod;

 

import java.util.Random;

 

import net.minecraft.src.BaseMod;

import net.minecraft.world.World;

 

public class mod_medmodextensionvillage extends BaseMod{

 

public Random ChunkGenRand;

public int ChunkGenRandNum = 0;

 

 

@Override

public String getVersion() {

 

 

 

return null;

}

@Override

public void load() {

 

 

}

 

public void generateSurface(World world, Random rand, int i, int j)

{

ChunkGenRand = new Random();

ChunkGenRandNum = ChunkGenRand.nextInt(8) + 1;

 

if(ChunkGenRandNum == 1)

{

for(int k = 0; k < 2; k++)

{

int RandPosX = i + rand.nextInt(16);

int RandPosZ = j + rand.nextInt(16);

int j1 = world.getHeightValue(RandPosX, RandPosZ);

(new WorldGenVillageMed()).generate(world, rand, RandPosX, j1, RandPosZ);

}

}

}

 

}

 

----------------------------------------------------------------------------------------------

 

package mod_medmod;

 

import java.util.Random;

 

import net.minecraft.block.Block;

import net.minecraft.world.World;

import net.minecraft.world.gen.feature.WorldGenerator;

import mod_medmod.main;

;

public class WorldGenVillageMed extends WorldGenerator

{

public WorldGenVillageMed()

{

 

}

 

public boolean generate(World world, Random rand, int i, int j, int k)

{

world.setBlockWithNotify(i, j, k, Block.blockDiamond.blockID);

 

 

return true;

 

}

}

 

---------------------------------------------------------------------------

 

Also If you know how, it would be highly appreciated if you could show me a method to put in so these blocks do not spawn on top of oceans and rivers,

thankyou

 

 

Link to comment
Share on other sites

You havent decleared a block like that inn your mod class as far as I can see?

 

public static final Block tileBlock= new BlockTileBlock(/* WHATEVER your constructor needs here /*);

 

Check out this tutorial, it should solve the problems you are having:

http://www.minecraftforge.net/wiki/Basic_Blocks

 

Also you might want to read the:

http://www.minecraftforge.net/wiki/Basic_Modding

just in case :)

If you guys dont get it.. then well ya.. try harder...

Link to comment
Share on other sites

Scratch that!

 

You are extending basemod which means you are creating a ModLoader mod using forge.

You should use the @mod annotation and never use extends basemod.

The only reason it works is for forge to be compitable with ModLoader mods!

 

Before you do ANYTHING else, go read up on this:

http://www.minecraftforge.net/wiki/Basic_Modding

 

That should get you on the right track! :)

Have fun coding!

 

PS: This might be even better, a mod tutorial you can read which creates a simple forge mod from start :)

http://www.minecraftforge.net/wiki/Tutorials/Making_the_base_mod_file

If you guys dont get it.. then well ya.. try harder...

Link to comment
Share on other sites

Hey I've been watching all of the tutorials, So I have just tried to make a simple Ore generation, but again I am still unable to load a block for generation. Here is my code.

 

--------------------------------------------------------------------------------------------------------------------------

 

package geodeMod;

 

 

import java.util.Random;

 

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

import net.minecraftforge.common.Configuration;

 

import cpw.mods.fml.common.Mod;

import cpw.mods.fml.common.Mod.Init;

import cpw.mods.fml.common.Mod.PreInit;

import cpw.mods.fml.common.SidedProxy;

import cpw.mods.fml.common.event.FMLInitializationEvent;

import cpw.mods.fml.common.event.FMLPreInitializationEvent;

import cpw.mods.fml.common.network.NetworkMod;

import cpw.mods.fml.common.registry.GameRegistry;

import cpw.mods.fml.common.registry.LanguageRegistry;

 

@Mod(modid="medmod", name="Med Mod", version="1.1")

 

@NetworkMod(clientSideRequired=true, serverSideRequired=false)

 

public class main

{

 

@SidedProxy(clientSide = "mod_medmod.ClientProxymod_medmod",

serverSide = "mod_medmod.common.CommonProxymod_medmod")

public static ClientProxymod_medmod proxy = new ClientProxymod_medmod();

 

Block GeodeBlock;

 

int GeodeBlockID;

 

@PreInit

public void preInti(FMLPreInitializationEvent event){

 

Configuration config = new Configuration(event.getSuggestedConfigurationFile());

 

GeodeBlockID = config.get("Block ID's", "GeodeBlock ID", 700).getInt();

 

config.save();

config.load();

}

    @Init

      public void load(FMLInitializationEvent event)

      { 

    GeodeBlock = new BlockGeodeBlock(GeodeBlockID, 3, Material.rock).setHardness(42F).setResistance(5F).setBlockName("GeodeBlock");

     

    gameRegisters();

    languageRegisters();

   

    proxy.registerRender();

     

      }   

    public void gameRegisters(){

   

    GameRegistry.registerBlock(GeodeBlock);

    GameRegistry.registerWorldGenerator(new WorldGenGeode());  

}

 

public void languageRegisters(){

LanguageRegistry.addName(GeodeBlock, "Geode Block");

}

 

      @PreInit

      public void init(FMLPreInitializationEvent preEvent)

      {

       

      }     

}

 

------------------------------------------------------------------------------------------

 

package geodeMod;

 

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

import net.minecraft.creativetab.CreativeTabs;

 

public class BlockGeodeBlock extends Block{

 

public BlockGeodeBlock(int id, int texture, Material mat){

super(id, texture, mat);

this.setCreativeTab(CreativeTabs.tabBlock);

}

 

public String getTextureFile(){

return "/mod_medmod/spritesheet.png";

}

 

}

 

------------------------------------------------------------------------------------------------------

 

package geodeMod;

import java.util.Random;

 

import cpw.mods.fml.common.IWorldGenerator;

import net.minecraft.src.*;

import net.minecraft.world.World;

import net.minecraft.world.chunk.IChunkProvider;

import net.minecraft.world.gen.feature.WorldGenMinable;

 

 

public class WorldGenGeode implements IWorldGenerator {

 

public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider){

 

 

switch(world.provider.dimensionId){

 

case 0: generateSurface(world, random, chunkX*16, chunkZ*16);

 

}

}

 

public void generateSurface(World world, Random random, int blockX, int blockZ){

 

int Xcoord = blockX + random.nextInt(16);

int Ycoord = random.nextInt(60);

int Zcoord = blockZ + random.nextInt(16);

(new WorldGenMinable(geodeMod.BlockGeodeBlock.blockID, 12)).generate(world, random, Xcoord, Ycoord, Zcoord);

 

}

public void generateNether(){

 

}

 

}

 

------------------------------------------------------------------------------------------------------

 

As usual the error is under (new WorldGenMinable(geodeMod.BlockGeodeBlock.blockID,

If you can find something wrong please tell me.

I'm also wondering if it is my project setup, my project goes as following

 

geodeMod (package)

  main(class)

 

 

Also last time Mazetar posted that I should use @mod annotations, but I am unsure of how to use that, If anyone has a good tutorial please tell me.

thanks

Link to comment
Share on other sites

@Mod(modid="medmod", name="Med Mod", version="1.1")

@NetworkMod(clientSideRequired=true, serverSideRequired=false)

 

Now you ARE using @Mod :)

Which you did not do above when you instead extended basemod.

A good tutorial for the @mod and basic modding would be the two I linked above along with:

http://wuppy29.blogspot.nl/2012/10/forge-modding-142.html

Wuppy has some great tutorials there, many which are inn video form in addition to text form :)

 

The error you are having is not from Forge inn this case, it's because you don't know Java very well.

I recommend that you watch(and do) these tutorials: http://thenewboston.org/list.php?cat=31

At least up to where he starts with Jframe and stuff, yes there are many of them but they are only 5-6 mins long!

They will make you better at modding minecraft and better at programming because you will learn the basics of the language you are using!

 

And to solve your problem:

The problem are with these lines of code.

Block GeodeBlock;

  int GeodeBlockID;

 

This video explains EVERYTHING about the error you are having and should resolve your problem inn the few minutes you are using to watch it: http://thenewboston.org/watch.php?cat=31&number=38

Trust me, it saves you time in the long run!

 

 

If you guys dont get it.. then well ya.. try harder...

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.



×
×
  • Create New...

Important Information

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