Jump to content

Solved


Dklory

Recommended Posts

There is block class

Learn java.

You construct your Biome (

new

is the keyword to construct a new instance) before you construct the Block. But then in your Biome constructor you refer to the Block instance (which doesn't exist yet, it's null. That causes a NPE).

 

look:

 

BlockClass redstone:

 

public class BlockRedStone extends Block{
    public BlockRedStone(int blockID)
    {
    	super(blockID, Material.rock);
    	this.setCreativeTab(mod_SecretMod.tabSecretMod);
    	setHardness(4.0f);
    	setResistance(4.0f);
    	setStepSound(soundStoneFootstep);
    }

    @Override
    public void registerIcons(IconRegister iconRegister)
    {
            blockIcon = iconRegister.registerIcon("secretmod:RedStone");
    }

}

 

blockclass red grass:

 

public class BlockRedGrass extends Block{
protected Icon[] textures = new Icon[3];
    public BlockRedGrass(int blockID)
    {
    	super(blockID, Material.ground);
    	this.setCreativeTab(mod_SecretMod.tabSecretMod);
    	setHardness(4.0f);
    	setResistance(6.0f);
    	setStepSound(soundStoneFootstep);
    }
    
    public boolean isOpaqueCube()
    {
    	return false;
    }
    public boolean renderAsNormalBlock()
    {
    	return false;   	
    }
    public int getRenderBlockPass()
    {
    	return 1;
    }
    @Override
    public void registerIcons(IconRegister iconRegister)
    {
    	textures[0] = iconRegister.registerIcon("secretmod:grass_side");
    	textures[1] = iconRegister.registerIcon("secretmod:grass_top");
    	textures[2] = iconRegister.registerIcon("secretmod:dirt");
           
    }
    
    @Override
    public Icon getIcon(int side, int meta)
    {
    	if(side==0){
    		return textures[2];
    	} else if (side==1){
    		return textures[1];
    	} else if (side==2){
    		return textures[0];
    	} else if (side==3){
    		return textures[0];
    	} else if (side==4){
    		return textures[0];
    	} else if (side==5){
    		return textures[0];
    	} else {
    		return textures[0];
    	}
    }
}

Link to comment
Share on other sites

Argh.

myBiome = new MyBiomeClass();
myBlock = new MyBlock();

That is what you have. Inside the MyBiomeClass constructor you have a reference to the myBlock field, which is still null at that point. Java executes your code from top to bottom.

 

I fix it, but when i create new world the biome is all iron ore

Link to comment
Share on other sites

I fix it, but when i create new world the biome is all iron ore

the block ID has to be below 256 to use it as a top or filler block.  This may change in the next version I think without block IDs but for now that's your issue.

 

how to solve this? because I want to make the biome with a custom block

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.