MC Modding
Please register and join the community!

[1.8.1] Crop

Page 1 of 2 1, 2  Next

View previous topic View next topic Go down

[1.8.1] Crop

Post by Strengthowns on Wed Oct 05, 2011 10:56 am

Crop

Spoiler:
ItemNamehere
Code:
package net.minecraft.src;

public class ItemNamehere extends Item
{

    public ItemNamehere(int i, int j)
    {
        super(i);
        field_318_a = j;
    }

    public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l)
    {
        if(l != 1)
        {
            return false;
        }
        if(!entityplayer.func_35190_e(i, j, k) || !entityplayer.func_35190_e(i, j + 1, k))
        {
            return false;
        }
        int i1 = world.getBlockId(i, j, k);
        if(i1 == Block.tilledField.blockID && world.isAirBlock(i, j + 1, k))
        {
            world.setBlockWithNotify(i, j + 1, k, field_318_a);
            itemstack.stackSize--;
            return true;
        } else
        {
            return false;
        }
    }

    private int field_318_a;
}

mod_Namehere
Code:
package net.minecraft.src;

import java.util.*;

public class mod_Namehere extends BaseMod
{
    public static int growNamehere1 = ModLoader.addOverride("/terrain.png", "/growNamehere1.png");
    public static int growNamehere2 = ModLoader.addOverride("/terrain.png", "/growNamehere2.png");
    public static int growNamehere3 = ModLoader.addOverride("/terrain.png", "/growNamehere3.png");
    public static int growNamehere4 = ModLoader.addOverride("/terrain.png", "/growNamehere4.png");
    public static int growNamehere5 = ModLoader.addOverride("/terrain.png", "/growNamehere5.png");
    public static int growNamehere6 = ModLoader.addOverride("/terrain.png", "/growNamehere6.png");
    public static int growNamehere7 = ModLoader.addOverride("/terrain.png", "/growNamehere7.png");
    public static int growNamehere8 = ModLoader.addOverride("/terrain.png", "/growNamehere8.png");
   
    public static final Block Nameherecrop = new BlockNameherecrop(200, 0).setBlockName("Nameherecrop");
    public static final Item Namehere = new ItemNamehere(4000, mod_Namehere.Nameherecrop.blockID).setItemName("Namehere");

    public mod_Namehere()
    {
        ModLoader.AddName(Nameherecrop, "Namehere Crop");
        Nameherecrop.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/Nameherecrop.png");
      
        ModLoader.AddName(Namehere, "Namehere");
        Namehere.iconIndex = ModLoader.addOverride("/gui/items.png", "/Namehere.png");
    }
   
   public String Version()
   {
      return "1.8.1";
   }
}

BlockNameherecrop
Code:
package net.minecraft.src;

import java.util.Random;

public class BlockNameherecrop extends BlockFlower
{

    protected BlockNameherecrop(int i, int j)
    {
        super(i, j);
        blockIndexInTexture = j;
        setTickOnLoad(true);
        float f = 0.5F;
        setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.25F, 0.5F + f);
    }

    protected boolean canThisPlantGrowOnThisBlockID(int i)
    {
        return i == Block.tilledField.blockID;
    }

    public void updateTick(World world, int i, int j, int k, Random random)
    {
        super.updateTick(world, i, j, k, random);
        if(world.getBlockLightValue(i, j + 1, k) >= 9)
        {
            int l = world.getBlockMetadata(i, j, k);
            if(l < 7)
            {
                float f = getGrowthRate(world, i, j, k);
                if(random.nextInt((int)(100F / f)) == 0)
                {
                    l++;
                    world.setBlockMetadataWithNotify(i, j, k, l);
                }
            }
        }
    }

    public void fertilize(World world, int i, int j, int k)
    {
        world.setBlockMetadataWithNotify(i, j, k, 7);
    }

    private float getGrowthRate(World world, int i, int j, int k)
    {
        float f = 1.0F;
        int l = world.getBlockId(i, j, k - 1);
        int i1 = world.getBlockId(i, j, k + 1);
        int j1 = world.getBlockId(i - 1, j, k);
        int k1 = world.getBlockId(i + 1, j, k);
        int l1 = world.getBlockId(i - 1, j, k - 1);
        int i2 = world.getBlockId(i + 1, j, k - 1);
        int j2 = world.getBlockId(i + 1, j, k + 1);
        int k2 = world.getBlockId(i - 1, j, k + 1);
        boolean flag = j1 == blockID || k1 == blockID;
        boolean flag1 = l == blockID || i1 == blockID;
        boolean flag2 = l1 == blockID || i2 == blockID || j2 == blockID || k2 == blockID;
        for(int l2 = i - 1; l2 <= i + 1; l2++)
        {
            for(int i3 = k - 1; i3 <= k + 1; i3++)
            {
                int j3 = world.getBlockId(l2, j - 1, i3);
                float f1 = 0.0F;
                if(j3 == Block.tilledField.blockID)
                {
                    f1 = 1.0F;
                    if(world.getBlockMetadata(l2, j - 1, i3) > 0)
                    {
                        f1 = 3F;
                    }
                }
                if(l2 != i || i3 != k)
                {
                    f1 /= 4F;
                }
                f += f1;
            }

        }

        if(flag2 || flag && flag1)
        {
            f /= 2.0F;
        }
        return f;
    }
 
    public int getBlockTextureFromSideAndMetadata(int i, int j)
    {
        if(j == 0)
        {
          return blockIndexInTexture;
        }
        if(j == 1)
        {
          return mod_Namehere.growNamehere1;
        }
        if(j == 2)
        {
          return mod_Namehere.growNamehere2;
        }
        if(j == 3)
        {
          return mod_Namehere.growNamehere3;
        }
        if(j == 4)
        {
          return mod_Namehere.growNamehere4;
        }
        if(j == 5)
        {
          return mod_Namehere.growNamehere5;
        }
        if(j == 6)
        {
          return mod_Namehere.growNamehere6;
        }
        if(j == 7)
        {
          return mod_Namehere.growNamehere7;
        }
        if(j == 8)
        {
          return mod_Namehere.growNamehere8;
        }
      return j;
    }

    public int getRenderType()
    {
        return 6;
    }

    public int idDropped(int i, Random random)
    {
        if(i == 5)
        {
            return Item.redstone.shiftedIndex;
        } else
        {
            return -1;
        }
    }
   

    public int quantityDropped(Random random)
    {
        return 1;
    }
}

Help: ItemNamehere

1. Just leave everything here as is. You can use this exact same code for any different seeds you want to do.

Help: mod_Namehere

1. All of the "public static int" parts at the top for textures means that you are just registering the textures for the stages in the crop's growth.

2. For the "public static final Item Namehere", after the ID you change the "mod_Blabla" to what crop you want it to place when you use it on the tilled field.

3. You should know the rest, refer to "Block" tutorial for more help on the basics.

Help: BlockNameherecrop

1. The "canThisPlantGrowOnThisBlockID" part is self explaining, this is what you want it to be able to grow on.

2. A little bit further down it has this line "if(world.getBlockLightValue(i, j + 1, k) >= 9)", change the ">= 9" to what ever light level you want it to grow in (Highest light level is 15, that's the brightest the sun goes). That part means that it will grow in a light level of either 9 or higher. You could also make it grow in a light value of say 6 or lower ("<= 6").

3. In the "getGrowthRate" you can change this part "float f = 1.0F;" to how fast you want it to grow.

4. The "getBlockTextureFromSideAndMetadata" part is just saying what textures it will use at what growth level.

5. In the "idDropped" bit, the 5 is how rare a chance it is of getting the redstone dust. (Higher the number, more rare of a drop it is)

6. "quantityDropped" is self explanatory, change it to how much of the block/item you want it to drop when it does.

7. That's it! Enjoy making your new crops!
avatar
Strengthowns
Admin

Posts : 79
Join date : 2011-06-14
Location : Right here!

View user profile http://www.mcmodding.4umer.com

Back to top Go down

Re: [1.8.1] Crop

Post by austin56101 on Mon Oct 24, 2011 9:15 am

Do you think you can make a video on this? I've tried several times, and I failed lol
avatar
austin56101
Moderator
Moderator

Posts : 85
Join date : 2011-10-22
Age : 21
Location : Cali!

View user profile

Back to top Go down

Re: [1.8.1] Crop

Post by austin56101 on Tue Oct 25, 2011 4:16 am

hey mannn can you comment on this?
also make bonemeal work?
avatar
austin56101
Moderator
Moderator

Posts : 85
Join date : 2011-10-22
Age : 21
Location : Cali!

View user profile

Back to top Go down

Re: [1.8.1] Crop

Post by Strengthowns on Tue Oct 25, 2011 8:43 am

Show me the error in the help section.
avatar
Strengthowns
Admin

Posts : 79
Join date : 2011-06-14
Location : Right here!

View user profile http://www.mcmodding.4umer.com

Back to top Go down

Re: [1.8.1] Crop

Post by lcass on Tue Oct 25, 2011 10:35 am

I get the thing working but It dosn't grow and it dosn' drop anything

lcass
Member

Posts : 145
Join date : 2011-10-24
Location : england

View user profile http://www.youtube.com/user/thealcasgroup

Back to top Go down

Re: [1.8.1] Crop

Post by austin56101 on Tue Oct 25, 2011 4:54 pm

Same^
avatar
austin56101
Moderator
Moderator

Posts : 85
Join date : 2011-10-22
Age : 21
Location : Cali!

View user profile

Back to top Go down

Re: [1.8.1] Crop

Post by lcass on Tue Oct 25, 2011 6:19 pm

well we dont get an error all that happens is it dosn't grow and bone meal dosn't work on it and then when you destroy it it dosn't return the item that was said in the namhere.java return method. DANG lots of dosn't

lcass
Member

Posts : 145
Join date : 2011-10-24
Location : england

View user profile http://www.youtube.com/user/thealcasgroup

Back to top Go down

Re: [1.8.1] Crop

Post by Strengthowns on Wed Oct 26, 2011 1:27 am

It should. I test all of the code for my tutorials and it works fine. I don't know what the problem is then. Show me your mod_ files.
avatar
Strengthowns
Admin

Posts : 79
Join date : 2011-06-14
Location : Right here!

View user profile http://www.mcmodding.4umer.com

Back to top Go down

Re: [1.8.1] Crop

Post by austin56101 on Wed Oct 26, 2011 4:33 am

well i deleted it (clean up) since it didnt work
also i just copied pasted and renamed
and it worked but they didnt grow
also didnt work with bone meal
avatar
austin56101
Moderator
Moderator

Posts : 85
Join date : 2011-10-22
Age : 21
Location : Cali!

View user profile

Back to top Go down

Re: [1.8.1] Crop

Post by groxmapper on Wed Oct 26, 2011 4:41 am

austin56101 wrote:well i deleted it (clean up) since it didnt work
also i just copied pasted and renamed
and it worked but they didnt grow
also didnt work with bone meal

Well it's garenteed not to work with bonemeal because the code for how bonemeal reacts to plants is in ItemDye.java not in the blocks it effects.
avatar
groxmapper
Member

Posts : 27
Join date : 2011-10-24

View user profile

Back to top Go down

Re: [1.8.1] Crop

Post by austin56101 on Wed Oct 26, 2011 4:44 am

well can it be restated to work here as well?
avatar
austin56101
Moderator
Moderator

Posts : 85
Join date : 2011-10-22
Age : 21
Location : Cali!

View user profile

Back to top Go down

Re: [1.8.1] Crop

Post by lcass on Wed Oct 26, 2011 12:01 pm

[code]package net.minecraft.src;

import java.util.*;

public class mod_superwheat extends BaseMod
{
public static int growsuperwheat1 = ModLoader.addOverride("/terrain.png", "/crystal/1wheat.png");
public static int growsuperwheat2 = ModLoader.addOverride("/terrain.png", "/crystal/2wheat.png");
public static int growsuperwheat3 = ModLoader.addOverride("/terrain.png", "/crystal/3wheat.png");
public static int growsuperwheat4 = ModLoader.addOverride("/terrain.png", "/crystal/4wheat.png");
public static int growsuperwheat5 = ModLoader.addOverride("/terrain.png", "/crystal/5wheat.png");
public static int growsuperwheat6 = ModLoader.addOverride("/terrain.png", "/crystal/6wheat.png");
public static int growsuperwheat7 = ModLoader.addOverride("/terrain.png", "/crystal/7wheat.png");
public static int growsuperwheat8 = ModLoader.addOverride("/terrain.png", "/crystal/8wheat.png");

public static final Block superwheatblock = new superwheatblock(200, 0).setBlockName("superwheat");
public static final Item superwheat = new superwheat(4000, mod_superwheat.superwheatblock.blockID).setItemName("superwheatblock");

public mod_superwheat()
{
ModLoader.AddName(superwheat, "superwheat");
superwheatblock.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/crystal/wheatblock.png");

ModLoader.AddName(superwheat, "superwheat");
superwheat.iconIndex = ModLoader.addOverride("/gui/items.png", "/crystal/wheatitem.png");
}

public String Version()
{
return "1.8.1";
}
}

lcass
Member

Posts : 145
Join date : 2011-10-24
Location : england

View user profile http://www.youtube.com/user/thealcasgroup

Back to top Go down

Re: [1.8.1] Crop

Post by groxmapper on Wed Oct 26, 2011 1:54 pm

austin56101 wrote:well can it be restated to work here as well?

In terms of bonemeal, unless you edit ItemDye.java you'll need to make a new item or use blockActivated like so:
Code:
public boolean blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer)
{
      if(entityplayer.inventory.getCurrentItem() != null && entityplayer.inventory.getCurrentItem().itemID == Item.bonemeal.shiftedIndex) // guessing on bonemeal, check Item.java if this doesn't work
       {   
//put sapling grow code here       
}else
      {
         super.blockActivated(world, i, j, k, entityplayer);
      }
}


Last edited by groxmapper on Wed Oct 26, 2011 9:41 pm; edited 1 time in total
avatar
groxmapper
Member

Posts : 27
Join date : 2011-10-24

View user profile

Back to top Go down

Re: [1.8.1] Crop

Post by austin56101 on Wed Oct 26, 2011 4:40 pm

Icass use code tags please, thanks:)
avatar
austin56101
Moderator
Moderator

Posts : 85
Join date : 2011-10-22
Age : 21
Location : Cali!

View user profile

Back to top Go down

Re: [1.8.1] Crop

Post by lcass on Wed Oct 26, 2011 5:58 pm

Very Happy I know it messed up GRATS on becoming mod ALSO austin I will be adding some tutorials aswell Very Happy I finally know how to do the furnace like item thing making anything you want Very Happy so many Very Happy I will put it up tonight (hopefully) I just spent the past to hours eating kit kats and meringues editing mojangs code to get it to function as a diffrent item!!!!!

lcass
Member

Posts : 145
Join date : 2011-10-24
Location : england

View user profile http://www.youtube.com/user/thealcasgroup

Back to top Go down

Re: [1.8.1] Crop

Post by austin56101 on Wed Oct 26, 2011 7:14 pm

Good aha I've been the only one adding tuts aha
And lolz
avatar
austin56101
Moderator
Moderator

Posts : 85
Join date : 2011-10-22
Age : 21
Location : Cali!

View user profile

Back to top Go down

Re: [1.8.1] Crop

Post by lcass on Wed Oct 26, 2011 10:45 pm

I will have an update on the newdimension coming soon

lcass
Member

Posts : 145
Join date : 2011-10-24
Location : england

View user profile http://www.youtube.com/user/thealcasgroup

Back to top Go down

Re: [1.8.1] Crop

Post by austin56101 on Wed Oct 26, 2011 11:16 pm

Sweet. Looking forward to it!
avatar
austin56101
Moderator
Moderator

Posts : 85
Join date : 2011-10-22
Age : 21
Location : Cali!

View user profile

Back to top Go down

Re: [1.8.1] Crop

Post by lcass on Wed Oct 26, 2011 11:25 pm

oh and how to make a bow and arrow I tried one on zidmc that was copyied from someone else by this kid like 7 years old Very Happy and guess what IT didn't work so I will do one here hopefull people will like it. yay i might be doing the coco mod Very Happy I do love my Very Happy s there epic

lcass
Member

Posts : 145
Join date : 2011-10-24
Location : england

View user profile http://www.youtube.com/user/thealcasgroup

Back to top Go down

Re: [1.8.1] Crop

Post by austin56101 on Wed Oct 26, 2011 11:38 pm

lol yeah
well all working tuts are welcome!
avatar
austin56101
Moderator
Moderator

Posts : 85
Join date : 2011-10-22
Age : 21
Location : Cali!

View user profile

Back to top Go down

Re: [1.8.1] Crop

Post by jesshankin22 on Sat Oct 29, 2011 5:54 am

Wait... if I used this exact code, pretty much, what would I use for seeds, if you know what I mean

jesshankin22
Member

Posts : 47
Join date : 2011-10-24

View user profile

Back to top Go down

Re: [1.8.1] Crop

Post by austin56101 on Sat Oct 29, 2011 6:15 am

idk i couldnt get it o work :/
like mine wouldnt grow
avatar
austin56101
Moderator
Moderator

Posts : 85
Join date : 2011-10-22
Age : 21
Location : Cali!

View user profile

Back to top Go down

Re: [1.8.1] Crop

Post by jesshankin22 on Sat Oct 29, 2011 6:18 am

yeah but what did you use as seeds?

jesshankin22
Member

Posts : 47
Join date : 2011-10-24

View user profile

Back to top Go down

Re: [1.8.1] Crop

Post by austin56101 on Sat Oct 29, 2011 6:19 am

not sure :/
avatar
austin56101
Moderator
Moderator

Posts : 85
Join date : 2011-10-22
Age : 21
Location : Cali!

View user profile

Back to top Go down

Re: [1.8.1] Crop

Post by jesshankin22 on Sat Oct 29, 2011 6:23 am

haha I see... damn =/ oh well.

jesshankin22
Member

Posts : 47
Join date : 2011-10-24

View user profile

Back to top Go down

Re: [1.8.1] Crop

Post by Sponsored content


Sponsored content


Back to top Go down

Page 1 of 2 1, 2  Next

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum