Posted February 23, 201411 yr Hi again, I wanted to create an item that you could use as a potion so that it gave you an effect when you used it, but you didn't drink it. I wrote some code, including adding a creative tab and adding an item, and it worked. I then changed the item from extending an Item that did nothing to extending an ItemPotion, added some functions, and things stopped working completely. Here's the code, and hopefully you can help: package com.pandassaurus.breakingbad; import com.pandassaurus.breakingbad.creativetabs.TabBreakingBadMod; import com.pandassaurus.breakingbad.item.GoodMeth; import com.pandassaurus.breakingbad.placeholder.BreakingBadPlaceholder; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.common.Mod; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @Mod(modid = BreakingBad.MODID, name = BreakingBad.NAME, version = BreakingBad.VERSION, useMetadata = true) public class BreakingBad { public static final String MODID = "breakingbad"; public static final String VERSION = "1.0"; public static final String NAME = "Breaking Bad Mod"; //Misc public static CreativeTabs TabBreakingBad = new TabBreakingBadMod(CreativeTabs.getNextID(), "Breaking Bad"); //Items static Item BlueMeth = new GoodMeth(2000).setUnlocalizedName("Crystal Blue"); public static Item BreakingBadPlaceHolder = new BreakingBadPlaceholder(2001).setUnlocalizedName("Breaking Bad Place Holder"); public BreakingBad() { GameRegistry.addRecipe(new ItemStack(BlueMeth, 1), "XxX", " * ", 'X', Item.coal, 'x', Item.sugar, '*', Item.diamond); LanguageRegistry.addName(BlueMeth, "Crystal Blue Meth"); } } package com.pandassaurus.breakingbad.creativetabs; import com.pandassaurus.breakingbad.BreakingBad; import net.minecraft.creativetab.CreativeTabs; /** * User: Pandassaurus * Date: 2/22/14 */ public class TabBreakingBadMod extends CreativeTabs { public TabBreakingBadMod(int par1, String par2Str) { super(par1, par2Str); } public int getTabIconItemIndex() { return BreakingBad.BreakingBadPlaceHolder.itemID; } public String getTranslatedTabLabel() { return "Breaking Bad"; } } package com.pandassaurus.breakingbad.item; import com.pandassaurus.breakingbad.BreakingBad; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumAction; import net.minecraft.item.ItemPotion; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.world.World; import java.util.List; /** * User: Pandassaurus * Date: 2/22/14 */ public class GoodMeth extends ItemPotion { public GoodMeth(int par1) { super(par1); this.setCreativeTab(BreakingBad.TabBreakingBadMod); } public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.confusion.id, 20, 3)); par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); return null; } public void registerIcons(IconRegister iconRegister) { itemIcon = iconRegister.registerIcon("modid:GoodMeth"); } public EnumAction getItemUseAction(ItemStack par1ItemStack) { return EnumAction.block; } public int getMaxItemUseDuration(ItemStack par1ItemStack) { return 32; } } if you could help that would be great. thanks, -Pandassaurus
February 24, 201411 yr I'm not seeing your FMLPreinitialization event handler where you should do most of your work, like creating and registering your blocks and items. That might break things. -S- (if I helped, please click Thank and applaud) http://6upnqa.dm2301.livefilestore.com/y2mtf-vG7Tqq1TiiVpIm53KWj7294NDPoHfSHHb4PzZiMAUfRCfK0UY0MwOu7Q3zTBNVTKqWjr2-xgBfFRpQT5p-QivtvknPpoABMNUw9br9WuZcBFkjePhnAbW500gVm-P/sequiturian.png[/img]
February 24, 201411 yr Author Is that needed? I didn't use that at first nor for previous mods, and it worked. I usually register and create the items in the main class. For this mod, the moment i changed the GoodMeth into an ItemPotion, it went cray cray, but i don't know if that's the reason. thanks, -Pandassaurus
February 24, 201411 yr Is that needed? Kinda. Yeah... Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
February 27, 201411 yr Author Is that needed? Kinda. Yeah... sorry for replying late, but how would you do it? I was looking online and found this code: @EventHandler public void preInit(FMLPreInitializationEvent event) { genericDirt = new GenericBlock(Material.ground) .setHardness(0.5F).setStepSound(Block.soundGravelFootstep) .setUnlocalizedName("genericDirt").setCreativeTab(CreativeTabs.tabBlock); genericOre = new GenericOre(Material.rock); MinecraftForge.setBlockHarvestLevel(genericDirt, "shovel", 0); GameRegistry.registerBlock(genericDirt, "genericDirt"); MinecraftForge.setBlockHarvestLevel(genericOre, "pickaxe", 3); GameRegistry.registerBlock(genericOre, "genericOre"); // End Basic Blocks proxy.registerRenderers(); } I thought you could declare all the block properties in the block classes themselves and declare them in the main class. I did it before and it worked. Is it because that code is for a different version? Thanks, Pandassaurus
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.