Jump to content

[Solved][1.7.10]Custom seed not planting.


skullcrusher1005

Recommended Posts

Hello Everyone, Lately I've been following Jabelar's modding tutorials. I've run into a problem where I can't plant the seed. I can go into NEI and get the crop's block itself and it'll work fine so I know it's not that. If anyone can help I would greatly appreciate it.

 

Coffee Bean class

 

package com.skullcrusher.BetterThings.items;

 

import com.skullcrusher.BetterThings.BetterThings;

import com.skullcrusher.BetterThings.ModSeeds;

 

import net.minecraft.init.Blocks;

import net.minecraftforge.common.IPlantable;

 

public class CoffeeBean extends ModSeeds

{

 

 

    public CoffeeBean()

    {

        super(1, 0.3F, BetterThings.CoffeePlant, Blocks.farmland);

    }

}

 

 

 

Mod Seed Class (Parent Class)

 

 

 

package com.skullcrusher.BetterThings;

 

import net.minecraft.block.Block;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.item.ItemFood;

import net.minecraft.item.ItemStack;

import net.minecraft.world.IBlockAccess;

import net.minecraft.world.World;

import net.minecraftforge.common.EnumPlantType;

import net.minecraftforge.common.IPlantable;

import net.minecraftforge.common.util.ForgeDirection;

 

public class ModSeeds extends ItemFood implements IPlantable

{

    private final Block theBlockPlant;

    /**

    * Block ID of the soil this seed food should be planted on.

    */

    private final Block soilId;

 

    public ModSeeds(int parHealAmount, float parSaturationModifier,

          Block parBlockPlant, Block parSoilBlock)

    {

        super(parHealAmount, parSaturationModifier, false);

        theBlockPlant = parBlockPlant;

        soilId = parSoilBlock;

    }

 

    @Override

    public boolean onItemUse(ItemStack parItemStack, EntityPlayer parPlayer,

          World parWorld, int parX, int parY, int parZ, int par7, float par8,

          float par9, float par10)

    {

    // not sure what this parameter does, copied it from potato

        if (par7 != 1)

        {

            return false;

        }

        // check if player has capability to edit

        else if (parPlayer.canPlayerEdit(parX, parY+1, parZ, par7, parItemStack))

        {

            // check that the soil block can sustain the plant

            // and that block above is air so there is room for plant to grow

            if (parWorld.getBlock(parX, parY, parZ).canSustainPlant(parWorld,

                  parX, parY, parZ, ForgeDirection.UP, this) && parWorld

                  .isAirBlock(parX, parY+1, parZ))

            {

            // place the plant block

                parWorld.setBlock(parX, parY+1, parZ, theBlockPlant);

                // decrement the stack of seed items

                --parItemStack.stackSize;

                return true;

            }

            else

            {

                return false;

            }

        }

        else

        {

            return false;

        }

    }

 

    @Override

    public EnumPlantType getPlantType(IBlockAccess world, int x, int y, int z)

    {

        return EnumPlantType.Crop;

    }

 

    @Override

    public Block getPlant(IBlockAccess world, int x, int y, int z)

    {

        return theBlockPlant;

    }

 

    @Override

    public int getPlantMetadata(IBlockAccess world, int x, int y, int z)

    {

        return 0;

    }

 

    public Block getSoilId()

    {

        return soilId;

    }

}

 

 

Link to comment
Share on other sites

Make sure your Block is initialized when you use it in the CoffeeBean class constructor.

 

It's initialized correctly, Here's the code in the PreInit handler

 

 

//Crops Stuff

CoffeePlant = new CoffeePlant().setBlockName("CoffeePlant").setCreativeTab(BetterThings).setHardness(0f).setResistance(0f).setBlockTextureName(modid + ":" + "Coffee_stage_0");

GameRegistry.registerBlock(CoffeePlant, "CoffeePlant");

CoffeeBean = new Item().setCreativeTab(BetterThings).setTextureName(modid + ":" + "CoffeeBean").setUnlocalizedName("CoffeeBean");

GameRegistry.registerItem(CoffeeBean, "CoffeeBean");

 

 

 

Also, At the top of the main mod class I have it like this

 

 

//Blocks

public static Block CoffeePlant;

 

//Seeds

public static Item CoffeeBean;

 

 

 

Link to comment
Share on other sites

CoffeeBean = new Item().setCreativeTab(BetterThings).setTextureName(modid + ":" + "CoffeeBean").setUnlocalizedName("CoffeeBean");

 

You use an ordinary Item, not your subclass.

 

Turns out that was the problem, I changed

 

CoffeeBean = new Item().setCreativeTab(BetterThings).setTextureName(modid + ":" + "CoffeeBean").setUnlocalizedName("CoffeeBean");

GameRegistry.registerItem(CoffeeBean, "CoffeeBean");

 

To:

 

CoffeeBean = new CoffeeBean().setCreativeTab(BetterThings).setTextureName(modid + ":" + "CoffeeBean").setUnlocalizedName("CoffeeBean");

GameRegistry.registerItem(CoffeeBean, "CoffeeBean");

 

Thanks alot man! :D

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • @bluedisgusted That actually fully fixed it, thank you so much
    • Hi, I would like to know how to create multiple hitboxes for the player like the ender dragon. I've searched everywhere but I haven't found anything.
    • FOLKWIN EXPERT RECOVERY is the crypto hero we all need in the ongoing battle against cryptocurrency theft. With the rise in popularity of digital assets like Bitcoin and Ethereum, crypto crime has also been on the rise as hackers look to steal funds stored in virtual wallets. Many a crypto investor has fallen victim to clever scams and hacking schemes that drain wallets of their precious coins. But fear not, for FOLKWIN EXPERT RECOVERY has arrived as a beacon of hope for those who have had their hard-earned crypto stolen. This service is like a superhero for tracking down lost or stolen cryptocurrency, utilizing their advanced forensic technology and expertise to follow the blockchain paper trail and identify where your funds have gone. Their team of ethical hackers act like detectives, piecing together crypto transactions and unmasking the thieves behind complex cybercrimes. No case is too difficult for FOLKWIN EXPERT RECOVERY; they have recovered millions in stolen crypto assets from around the globe. Their mission is to reunite victims with their lost funds and bring criminals who prey on cryptocurrency investors to justice. With their help, those who have been robbed of their digital fortunes now have a crypto guardian to call upon in their time of need. FOLKWIN EXPERT RECOVERY gives victims the hope that all is not lost forever when crypto theft occurs.For support, Contact details is: TELEGRAM: @FOLKWIN_EXPERT_RECOVERY, EMAIL: FOLKWINEXPERTRECOVERY at TECH-CENTER dot COM, WEBSITE: WWW.FOLKWINEXPERTRECOVERY.COM .  are the heroes we need in the ongoing battle to make cryptocurrency ownership safe and secure for all. Get FOLKWIN EXPERT RECOVERY on your side when you have issues like this by dialing: Do this and thank me later. God Blessings to all, I'm forever grateful oh God for the successful recovery. I recommend FOLKWIN EXPERT RECOVERY the best ever and i'm so happy i got all my lost money back. Best Regards. Pamela K Ingram.
    • Made it work. As a note, one of the times it didn't recognize the recipe cause the MOD_ID constant I was using somewhere was NOT referencing my MOD_ID but rather another static variable with the same name. Maybe OP is having a similar problem
    • What exactly is the issue?
  • Topics

×
×
  • Create New...

Important Information

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