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

  • Author

So many Errors :( ... Rendering doesn't work too btw :(

PowerApplesMain:

 

package de.UnknownAssassin.PowerApples;

 

import de.UnknownAssassin.PowerApples.ItemDiamondApple;

import net.minecraft.client.Minecraft;

import net.minecraft.client.resources.model.ModelResourceLocation;

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.init.Blocks;

import net.minecraft.init.Items;

import net.minecraft.item.Item;

import net.minecraft.item.ItemFood;

import net.minecraft.item.ItemStack;

import net.minecraft.potion.Potion;

import net.minecraft.potion.PotionEffect;

import net.minecraftforge.fml.common.Mod;

import net.minecraftforge.fml.common.Mod.EventHandler;

import net.minecraftforge.fml.common.event.FMLInitializationEvent;

import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;

import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;

import net.minecraftforge.fml.common.registry.GameRegistry;

 

@Mod(modid = PowerApplesMain.MODID, version = PowerApplesMain.VERSION)

public class PowerApplesMain

{

    public static final String MODID = "powerapples";

    public static final String VERSION = "Alpha";

   

    public static Item diamondapple;

   

    public static CreativeTabs PowerApplesTab;

   

    @EventHandler

    public void preinit(FMLPreInitializationEvent event)

    {

    PowerApplesTab = new CreativeTabs("PowerApplesTab")

    {

    @Override

    public Item getTabIconItem(){

    return Items.apple;

    }

    };

    diamondapple = new ItemDiamondApple(0, false).setUnlocalizedName("DiamondApple").setCreativeTab(PowerApplesTab).setMaxStackSize(4);

    diamondapple = new PotionEffect(Potion.moveSpeed.id, 1200, 1)

    }

   

    @EventHandler

    public void init(FMLInitializationEvent event)

    {

    //Crafting Rezepte

    GameRegistry.addRecipe(new ItemStack(Items.diamond, 1), new Object[]

    {

    "ddd",

    "dad",

    "ddd",

    Character.valueOf('d'), Items.diamond,

    Character.valueOf('a'), Items.apple

    });

    //Register Items

    GameRegistry.registerItem(diamondapple, "DiamondApple");

    Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(diamondapple, 0, new ModelResourceLocation("powerapples:diamondapple", "inventory"));

   

    }

    @EventHandler

    public void postinit(FMLPostInitializationEvent event)

    {

    }

}

 

 

ItemDiamondApple:

 

 

package de.UnknownAssassin.PowerApples;

 

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.item.Item;

import net.minecraft.item.ItemFood;

import net.minecraft.item.ItemStack;

import net.minecraft.potion.PotionEffect;

import net.minecraft.world.World;

 

public class ItemDiamondApple extends ItemFood

{

 

private PotionEffect[] effects;

 

ItemDiamondApple(String "DiamondApple", int healAmount,

    float saturationModifier, boolean wolvesFavourite,

    PotionEffect effects);

this.effects = effects;

 

}

 

@Override

protected void onFoodEaten(ItemStack stack, World world, EntityPlayer player) {

    super.onFoodEaten(stack, world, player);

       

    for (int i = 0; i < effects.length; i ++) {

        if (effects != null && effects.getPotionID() > 0)

            player.addPotionEffect(new PotionEffect(this.effects.getPotionID(), this.effects.getDuration(), this.effects.getAmplifier(), this.effects.getIsAmbient()));

}

}

 

 

Not to be offensive, but seeing you code I can assume you don't know much about how objects work in java.

    diamondapple = new ItemDiamondApple(0, false).setUnlocalizedName("DiamondApple").setCreativeTab(PowerApplesTab).setMaxStackSize(4);

    diamondapple = new PotionEffect(Potion.moveSpeed.id, 1200, 1)

 

1. Use [.code]code[./code] on forums when you paste stuff. (without dots)

2. Learn more Java - this is probably best advice you will find here.

1.7.10 is no longer supported by forge, you are on your own.

Because of the Forgotten ; ?

 

That wasn't really the issue. You should check out how Object declaration/initialization works. Understand what = new means and why is making new object of different class giving error when declared to non-same object field - which is what you did and I pointed out.

 

What you did: Initialized new Item, just to next line after re-init it with totally different object which is not only waste of initialization operation, but also in wrong type.

 

I can't really help you here but to point basic java mistakes and steer you to google and find tutorial on how to add effect to food - there is a LOT of it there, but 1st get some more of that java :)

1.7.10 is no longer supported by forge, you are on your own.

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.