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.

Featured Replies

Posted

after update to forge 4.2.5 build 303, have a small problem, OK changing the ItemsSeeds to the new IPlantable, but now the ItemDamage not work.

 

 

 

package betterworld.PlantsAndFood.common.items;

import betterworld.PlantsAndFood.common.BetterWorldPlantsAndFood;
import net.minecraft.src.Block;
import net.minecraft.src.CreativeTabs;
import net.minecraft.src.EntityLiving;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.Item;
import net.minecraft.src.ItemStack;
import net.minecraft.src.World;
import net.minecraftforge.common.EnumPlantType;
import net.minecraftforge.common.IPlantable;

public class ItemSeedsBag extends Item implements IPlantable
{
    private int blockType;
    private int soilBlockID1;
    private int soilBlockID2;

    public ItemSeedsBag(int par1, int par2, int par3, int texture)
    {
        super(par1);
        this.blockType = par2;
        this.soilBlockID1 = par3;
        this.setMaxDamage(32);
        setIconIndex(texture);
        this.setCreativeTab(CreativeTabs.tabMaterials);
    }

    public boolean tryPlaceIntoWorld(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
    {
        if (par7 != 1)
        {
            return false;
        }
        else if (par2EntityPlayer.canPlayerEdit(par4, par5, par6) && par2EntityPlayer.canPlayerEdit(par4, par5 + 1, par6))
        {
            int var11 = par3World.getBlockId(par4, par5, par6);
           
            if (var11 == this.soilBlockID1 && par3World.isAirBlock(par4, par5 + 1, par6))
            {
            	
                par3World.setBlockWithNotify(par4, par5 + 1, par6, this.blockType);
              // --par1ItemStack.stackSize;
                par1ItemStack.damageItem(1, par2EntityPlayer);
               
                return true;
            }

            else
            {
                return false;
            }
        }
        else
        {
            return false;
        }
    }
    public String getTextureFile()
    {
        return "/betterworld/textures/PlantsAndFood/items.png";
    }

    @Override
    public EnumPlantType getPlantType(World world, int x, int y, int z)
    {
        return (blockType == Block.netherStalk.blockID ? EnumPlantType.Nether : EnumPlantType.Crop);
    }

    @Override
    public int getPlantID(World world, int x, int y, int z)
    {
        return blockType;
    }

    @Override
    public int getPlantMetadata(World world, int x, int y, int z)
    {
        return 0;
    }
}

 

 

normaly use this:

    par1ItemStack.damageItem(1, par2EntityPlayer);

There are more changes in 4.2.5?

 

If I understood correctly, you're making a seed bag that can be used a number of times, right? Maybe you have to override the "isDamageable" function to return true?

  • Author

If I understood correctly, you're making a seed bag that can be used a number of times, right? Maybe you have to override the "isDamageable" function to return true?

 

Thanks for the try, but not help.

Found the Error in my old code i use:

public boolean tryPlaceIntoWorld(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
   

only for seeds work but not more for ItemDamage.

must change it to "onItemUse"

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

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.