Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[1.7.2][SOLVED]Custom crop drops wheat seeds and wheat(Not what I want it to)

Featured Replies

Posted

It is supposed to be dropping Quartz Seeds and a Quartz Block. Instead, it drops Wheat and Seeds. Also, if anyone knows how, I would like to set the percentage of the time each thing drops. I am updating from 1.6.4.

 

Here is my code:

 

 

 

package f1repl4ce.unlogic.blocks;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import f1repl4ce.unlogic.unbase;
import net.minecraft.block.Block;
import net.minecraft.block.BlockCrops;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.util.IIcon;

public class QuartzCrop extends BlockCrops{

@SideOnly(Side.CLIENT)
private IIcon[] iconArray;
public QuartzCrop(int par1) {
super();
}

@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata){
if(metadata < 7){
if(metadata == 6){
metadata = 5;
}
return iconArray[metadata >> 1];
}
return iconArray[4];
}

public Item getSeedItem(){
return unbase.QSeed;
}

public Block getCropItem(){
return Blocks.quartz_block;
}

@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister){
this.iconArray = new IIcon[5];

for(int i = 0; i < this.iconArray.length; i++){
this.iconArray[i] = iconRegister.registerIcon("unlogic:QCrop_" + (i+1));
}
}

}

 

 

 

And the Mod Base:

 

 

 

package f1repl4ce.unlogic;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemSeeds;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import f1repl4ce.unlogic.proxy.*;
import f1repl4ce.unlogic.items.*;
import f1repl4ce.unlogic.blocks.*;

@Mod(modid="unlogic", name="UnLogic", version="0.1.0")
public class unbase {

// The instance of your mod that Forge uses.
@Instance(value = "unlogic")
public static unbase instance;
//Creative Tab Registry
public static CreativeTabs TabUnLogic = new TabUnLogic(CreativeTabs.getNextID(), "UnLogic");
//Block Registry
public static Block QCrop = new QuartzCrop(2481);
public static Block FarmObsidian = new FarmObsidian(2482, Material.rock);
//Item Registry
public static Item Component = new Component(16794).setUnlocalizedName("Component_UN").setCreativeTab(TabUnLogic);
public static Item QSeed = new ItemSeeds(QCrop, Blocks.farmland/*FarmObsidian*/).setUnlocalizedName("QSeed").setTextureName("unlogic:QSeeds").setCreativeTab(TabUnLogic);

// Says where the client and server 'proxy' code is loaded.
@SidedProxy(clientSide="f1repl4ce.unlogic.proxy.Client", serverSide="f1repl4ce.unlogic.proxy.Common")
public static Common proxy;

@EventHandler
public void preInit(FMLPreInitializationEvent event) {
LanguageRegistry.instance().addStringLocalization("item.Component_UN.unlogicGem.name", "en_US", "UnLogic Gem");
LanguageRegistry.instance().addStringLocalization("item.Component_UN.fireCore.name", "en_US", "Fire Core");
LanguageRegistry.instance().addStringLocalization("item.Component_UN.iceCore.name", "en_US", "Ice Core");
LanguageRegistry.instance().addStringLocalization("item.Component_UN.antiGold.name", "en_US", "Anti-Gold");
LanguageRegistry.instance().addStringLocalization("item.Component_UN.redGem.name", "en_US", "Red Gem");
LanguageRegistry.instance().addStringLocalization("item.Component_UN.blueGem.name", "en_US", "Blue Gem");
LanguageRegistry.addName(QSeed, "Nether Quartz Seeds");
LanguageRegistry.addName(FarmObsidian, "Obsidian Farmland");
GameRegistry.registerBlock(QCrop, "Quartz Crop");
GameRegistry.registerBlock(FarmObsidian, "Obsidian Farmland");
GameRegistry.registerItem(QSeed, "Qseed");
GameRegistry.registerItem(Component, "Component");
ItemStack fireCore = new ItemStack(Component, 1, 1);
ItemStack iceCore = new ItemStack(Component, 1, 2);
ItemStack unlogicGem = new ItemStack(Component, 1, 0);
ItemStack seedStack = new ItemStack(Items.wheat_seeds);
ItemStack redGemStack = new ItemStack(Component, 1, 4);
ItemStack blueGemStack = new ItemStack(Component, 1, 5);
ItemStack qSeedStack = new ItemStack(QSeed);
ItemStack quartzStack = new ItemStack(Items.quartz);
OreDictionary.registerOre("fireCore", fireCore);
OreDictionary.registerOre("iceCore", iceCore);
GameRegistry.addRecipe(unlogicGem, "xy", "yx",
'x', redGemStack, 'y', blueGemStack);
GameRegistry.addRecipe(unlogicGem, "yx", "xy",
'x', redGemStack, 'y', blueGemStack);
GameRegistry.addRecipe(qSeedStack, "sus", "uqu", "sus",
's', seedStack, 'u', unlogicGem, 'q', quartzStack);
GameRegistry.addSmelting(Blocks.redstone_block, redGemStack, 10);
GameRegistry.addSmelting(Blocks.lapis_block, blueGemStack, 10);
}

@EventHandler
public void load(FMLInitializationEvent event) {
proxy.registerRenderers();
}

@EventHandler
public void postInit(FMLPostInitializationEvent event) {
}
}

 

 

 

If any code you need to see is missing, tell me and I'll add it.

If I helped please press the Thank You button.

 

Check out my mods at http://www.curse.com/users/The_Fireplace/projects

  • 2 months later...

You need to use the functions of the extended class

 

 

protected Item func_149866_i()

    {

        return Items.wheat_seeds;

    }

 

    protected Item func_149865_P()

    {

        return Items.wheat;

    }

package yourpackage;

 

import java.util.Random;

 

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

import net.minecraft.block.material.Material;

import net.minecraft.block.Block;

import net.minecraft.block.BlockCrops;

import net.minecraft.client.renderer.texture.IIconRegister;

import net.minecraft.init.Items;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraft.util.AxisAlignedBB;

import net.minecraft.util.IIcon;

import net.minecraft.world.World;

 

 

public class yourcrop extends BlockCrops{

 

public yourcrop() {

super();

 

 

 

}

@SideOnly(Side.CLIENT)

    private IIcon[] field_149869_a;

    private static final String __OBFID = "CL_00000286";

 

    /**

    * Gets the block's texture. Args: side, meta

    */

    @SideOnly(Side.CLIENT)

    public IIcon getIcon(int p_149691_1_, int p_149691_2_)

    {

        if (p_149691_2_ < 7)

        {

            if (p_149691_2_ == 6)

            {

                p_149691_2_ = 5;

            }

 

            return this.field_149869_a[p_149691_2_ >> 1];

        }

        else

        {

            return this.field_149869_a[3];

        }

    }

 

   

    protected Item func_149866_i()

    {

    return **DROP always**

   

   

       

       

       

    }

   

   

   

    protected Item func_149865_P()

    {

    return **DROP if full grown**

   

    }

 

   

 

/**

    * Drops the block items with a specified chance of dropping the specified items

    */

    public void dropBlockAsItemWithChance(World p_149690_1_, int p_149690_2_, int p_149690_3_, int p_149690_4_, int p_149690_5_, float p_149690_6_, int p_149690_7_)

    {

        super.dropBlockAsItemWithChance(p_149690_1_, p_149690_2_, p_149690_3_, p_149690_4_, p_149690_5_, p_149690_6_, p_149690_7_);

 

        if (!p_149690_1_.isRemote)

        {

            if (p_149690_5_ >= 7 && p_149690_1_.rand.nextInt(50) == 0)

            {

                this.dropBlockAsItem(p_149690_1_, p_149690_2_, p_149690_3_, p_149690_4_, new ItemStack(Items.string));

            }

        }

    }

 

    @SideOnly(Side.CLIENT)

    public void registerBlockIcons(IIconRegister p_149651_1_)

   

    {

        this.field_149869_a = new IIcon[4];

 

        for (int i = 0; i < this.field_149869_a.length; ++i)

        {

       

        int stage = 0;

if(i==0)

{

stage = 0;

}

if(i==1)

{

stage = 1;

}

if(i==2)

{

stage = 2;

}

if(i==3)

{

stage = 3;

}

            }

            this.field_149869_a = p_149651_1_.registerIcon("yourtexturefile" + "_" + stage);

        }

     

       

       

    }

 

 

   

 

}

  • 4 weeks later...

(sorry for bad english, i'm from venezuela)

Override this methods on your crop

@Override
    public Item getItemDropped(int meta, Random random, int fortune) //get drop item based on meta
    {
        return meta == 7 ? this.getCropItem() : this.getSeedItem();
    }

    @SideOnly(Side.CLIENT)
    public Item getItem(World world, int x, int y, int z) //get item with mouse wheel
    {
        return this.getSeedItem();
    }

   @Override
    public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) //get drops array
    {
        ArrayList<ItemStack> drops = new ArrayList<ItemStack>();

        int count = quantityDropped(metadata, fortune, world.rand);
        for(int i = 0; i < count; i++)
        {
            Item item = getItemDropped(metadata, world.rand, fortune);
            if (item != null)
            {
                drops.add(new ItemStack(item, 1, damageDropped(metadata)));
            }
        }
        
        if (metadata >= 7)
        {
            for (int i = 0; i < 3 + fortune; ++i)
            {
                if (world.rand.nextInt(15) <= metadata)
                {
                    drops.add(new ItemStack(this.getSeedItem(), 1, 0)); //<-- here
                }
            }
        }
        
        return drops;
    }

Making mods is fun!!!

(sorry bad english, i'm from venezuela)

Guest
This topic is now closed to further replies.

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.