Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[Solved][1.7.10]Custom seed not planting.


skullcrusher1005
 Share

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
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.

 Share



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • C:\Users\trodd\OneDrive\Desktop\server for 35>java -Xmx5G -Xms5G -jar forge-1.16.5-36.2.2.jar nogui 2022-05-27 09:49:55,394 main WARN Advanced terminal features are not available in this environment [09:49:55] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher running: args [--gameDir, ., --launchTarget, fmlserver, --fml.forgeVersion, 36.2.2, --fml.mcpVersion, 20210115.111550, --fml.mcVersion, 1.16.5, --fml.forgeGroup, net.minecraftforge, nogui] [09:49:55] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher 8.0.9+86+master.3cf110c starting: java version 1.8.0_333 by Oracle Corporation [09:49:56] [main/INFO] [ne.mi.fm.lo.FixSSL/CORE]: Added Lets Encrypt root certificates as additional trust [09:49:56] [main/INFO] [mixin/]: SpongePowered MIXIN Subsystem Version=0.8.2 Source=file:/C:/Users/trodd/OneDrive/Desktop/server%20for%2035/libraries/org/spongepowered/mixin/0.8.2/mixin-0.8.2.jar Service=ModLauncher Env=SERVER [09:49:57] [main/INFO] [STDERR/]: [org.antlr.v4.runtime.ConsoleErrorListener:syntaxError:38]: line 1:0 token recognition error at: '~' Exception in thread "main" [09:49:57] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]: java.lang.NoSuchMethodError: sun.security.util.ManifestEntryVerifier.<init>(Ljava/util/jar/Manifest;)V [09:49:57] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at cpw.mods.modlauncher.SecureJarHandler.createCodeSource(SecureJarHandler.java:66) [09:49:57] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at cpw.mods.modlauncher.TransformingClassLoader$DelegatedClassLoader.findClass(TransformingClassLoader.java:275) [09:49:57] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:136) [09:49:57] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:98) [09:49:57] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at java.lang.ClassLoader.loadClass(Unknown Source) [09:49:57] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at java.lang.Class.forName0(Native Method) [09:49:57] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at java.lang.Class.forName(Unknown Source) [09:49:57] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at org.spongepowered.asm.service.modlauncher.ModLauncherClassProvider.findClass(ModLauncherClassProvider.java:57) [09:49:57] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at org.spongepowered.asm.launch.platform.MixinConnectorManager.loadConnectors(MixinConnectorManager.java:71) [09:49:57] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at org.spongepowered.asm.launch.platform.MixinConnectorManager.inject(MixinConnectorManager.java:60) [09:49:57] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at org.spongepowered.asm.launch.platform.MixinPlatformManager.inject(MixinPlatformManager.java:197) [09:49:57] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at org.spongepowered.asm.launch.MixinBootstrap.inject(MixinBootstrap.java:190) [09:49:57] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at org.spongepowered.asm.launch.MixinLaunchPlugin.initializeLaunch(MixinLaunchPlugin.java:196) [09:49:57] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at cpw.mods.modlauncher.LaunchPluginHandler.lambda$announceLaunch$9(LaunchPluginHandler.java:97) [09:49:57] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at java.util.HashMap.forEach(Unknown Source) [09:49:57] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at cpw.mods.modlauncher.LaunchPluginHandler.announceLaunch(LaunchPluginHandler.java:97) [09:49:57] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:52) [09:49:57] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [09:49:57] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at cpw.mods.modlauncher.Launcher.run(Launcher.java:82) [09:49:57] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at cpw.mods.modlauncher.Launcher.main(Launcher.java:66) [09:49:57] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at net.minecraftforge.server.ServerMain$Runner.runLauncher(ServerMain.java:63) [09:49:57] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at net.minecraftforge.server.ServerMain$Runner.access$100(ServerMain.java:60) [09:49:57] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at net.minecraftforge.server.ServerMain.main(ServerMain.java:57) C:\Users\trodd\OneDrive\Desktop\server for 35>PAUSE Press any key to continue . . .  
    • I know I'm the worst, but where would that be in my code to create a new instance?
    • the class does not change the result, but i would recommend you to create a new class for the Item a thing you need to do is create a new instance of the class inside the RegistryObject instead of using the Item class  
    • There happened to be a few simple logic mistakes. I now get the correct sound out and a correct value is printed out on server, but on client it is still 0 for some reason.
    • Not sure, I haven't dug into the minecart code that much. The only problem I see is that this: Math.pow(targetVelocity, 2) - Math.pow(entryVelocity, 2) Is guaranteed to return a negative value, which when multiplied against entity motion would cause the entity to reverse direction.
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.