Jump to content

Recommended Posts

Posted

I have a problem with my ore being generated and it doesn't accept the texture code. First it was only the texture but I thought I will deal with it later. Then when I added water generation (like the clay generation code) it wouldn't generate.

 

Main class:

 

  Reveal hidden contents

 

 

Ore class

 

  Reveal hidden contents

 

 

Ore generation class

 

  Reveal hidden contents

 

Posted
  On 11/29/2013 at 10:40 PM, Sirpwnsamin said:

To fix the texture bug, instead of RegisterIcons (), add this.setTextureName("FirstMod:RedOre") under this.setResistance

The more advanced way of doing that is adding this method to your block class. It allows more control for all the sides and stuff, just for later purpose.

package first.mod.block;

// imports

public class RedOre extends Block{

   public RedOre(int par1, Material par2Material) {
      super(par1, par2Material);
      this.setCreativeTab(Base.TabRed);
      this.setHardness(10);
      this.setResistance(5);
   }
   
  @SideOnly( Side.CLIENT )
   public void RegisterIcons(IconRegister iconRegister){
      blockIcon = iconRegister.registerIcon("FirstMod:RedOre");
   }
   
   @SideOnly( Side.CLIENT )
   public Icont getIcon(int side, int meta ) {
       return this.blockIcon;
   }
   
    public int idDropped(int par1, Random par2Random, int par3)
    {
        return Base.RedThing.itemID;
    }
}

this.setTextureName does this automatically, but I still wanted to point that out.

 

And for the not generating part.. just check this really nice tutorial for that, I mean you need IWorldGenerator and you need to register it with GameRegistry.registerWorldGenerator( x.class ); in your FMLInitializationEvent.

 

Anyway, just check this tutorial out for that.

I am fairly new to Java and modding, so my answers are not always 100% correct. Sorry for that!

Posted

OK so it is spawning and accepting texture now only 1 more thing. I set up this code so it would generate in the ocean but I didn't found it anywhere. It didn't generate. Why?

System.out.println is only for validating it spawned it prints it but I can't find it.

private void generateSurface(World world, Random rand, int chunkX, int chunkZ) {
        if (world.getBiomeGenForCoords(chunkX, chunkZ) == BiomeGenBase.ocean){
        for(int k = 0; k < 10; k++){
        	int firstBlockXCoord = chunkX + rand.nextInt(16);
        	int firstBlockYCoord = rand.nextInt(32);
        	int firstBlockZCoord = chunkZ + rand.nextInt(16);
        	
        	(new WorldGenMinable(Base.RedOre.blockID, 15)).generate(world, rand, firstBlockXCoord, firstBlockYCoord, firstBlockZCoord);
        	System.out.println("spawned");
        }
	}
	}

Posted

Would this workout?

private void generateSurface(World world, Random rand, int chunkX, int chunkZ) {
		int firstBlockXCoord = chunkX + rand.nextInt(16);
        	int firstBlockYCoord = rand.nextInt(32);
        	int firstBlockZCoord = chunkZ + rand.nextInt(16);
        	
		if (world.getBiomeGenForCoords(firstBlockXCoord, firstBlockZCoord) == BiomeGenBase.ocean){
        for(int k = 0; k < 10; k++){
        	 firstBlockXCoord = chunkX + rand.nextInt(16);
        	 firstBlockYCoord = rand.nextInt(32);
        	 firstBlockZCoord = chunkZ + rand.nextInt(16);
        	
        	(new WorldGenMinable(Base.RedOre.blockID, 15)).generate(world, rand, firstBlockXCoord, firstBlockYCoord, firstBlockZCoord);
        	System.out.println("spawned");
        }
	}
	}

 

The ocean is huge so I don't know how much time would it take to find it.

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.