Posted February 26, 201510 yr I can't find out how to add Potion Effects to Food? ( 1.8 ) Pls help me Thank you
February 26, 201510 yr http://bedrockminer.jimdo.com/modding-tutorials/basic-modding/custom-food/ Maker of the Craft++ mod.
February 26, 201510 yr 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())); } }
February 26, 201510 yr 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.
February 26, 201510 yr Author Because of the Forgotten ; ? I already learned much Java but I can't say that it helped
February 26, 201510 yr 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.