Jump to content

Making / Generating a Fern like Plant!


Csfreakable

Recommended Posts

All I tried.. dont works.. with this codes, game crashes while generting:

My Codes:

mod_ Generation part:

{
for(int k = 0; k < 7; k++)
{
int genX = chunkX + random.nextInt(16);
int genY = 65;
int genZ = chunkZ + random.nextInt(16);
(new WorldGenTomato(tomatograss.blockID)).generate(world, random, genX, genY, genZ);
}
}

 

blocktomatograss:

 

package net.minecraft.src;
import java.util.ArrayList;
import java.util.Random;
import net.minecraft.src.forge.ITextureProvider;
public class Blocktomatograss extends BlockFlower implements ITextureProvider
{
protected Blocktomatograss(int par1, int par2)
{
     super(par1, par2, Material.vine);
     float var3 = 0.4F;
     this.setBlockBounds(0.5F - var3, 0.0F, 0.5F - var3, 0.5F + var3, 0.8F, 0.5F + var3);
}
/**
     * Gets passed in the blockID of the block below and supposed to return true if its allowed to grow on the type of
     * blockID passed in. Args: blockID
     */
protected boolean canThisPlantGrowOnThisBlockID(int par1)
{
     return par1 == Block.grass.blockID;
}
/**
     * From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
     */
public int getBlockTextureFromSideAndMetadata(int par1, int par2)
{
     return this.blockIndexInTexture;
}
/**
     * Returns the ID of the items to drop on destruction.
     */
public int idDropped(int meta, Random random, int i)
{
     return mod_foodMiP.tomatoseed.shiftedIndex;
}
/**
     * Called when the player destroys a block with an item that can harvest it. (i, j, k) are the coordinates of the
     * block and l is the block's subtype/damage.
     */
public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6)
{
     if (!par1World.isRemote && par2EntityPlayer.getCurrentEquippedItem() != null && par2EntityPlayer.getCurrentEquippedItem().itemID == Item.shears.shiftedIndex)
     {
         par2EntityPlayer.addStat(StatList.mineBlockStatArray[this.blockID], 1);
         this.dropBlockAsItem_do(par1World, par3, par4, par5, new ItemStack(mod_foodMiP.tomatograss, 1, par6));
     }
     else
     {
         super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6);
     }
}
public String getTextureFile()
{
     return "/MiningPlus/food/terrain.png";
}
public void addCreativeItems(ArrayList itemList)
{
         itemList.add(new ItemStack(this));
}
}

 

WorldGenTomato: ( i took code from WorldGenDeadBush)

 

package net.minecraft.src;
import java.util.Random;
public class WorldGenTomato extends WorldGenerator
{
/** The ID of the plant block used in this plant generator. */
private int TomatoId;
public WorldGenTomato(int par1)
{
     this.TomatoId = par1;
}
public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5)
{
     for (int var6 = 0; var6 < 64; ++var6)
     {
         int var7 = par3 + par2Random.nextInt( - par2Random.nextInt(;
         int var8 = par4 + par2Random.nextInt(4) - par2Random.nextInt(4);
         int var9 = par5 + par2Random.nextInt( - par2Random.nextInt(;
         if (par1World.isAirBlock(var7, var8, var9) && ((BlockFlower)Block.blocksList[this.TomatoId]).canBlockStay(par1World, var7, var8, var9))
         {
             par1World.setBlock(var7, var8, var9, this.TomatoId);
         }
     }
     return true;
}
}

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.