Posted June 18, 201411 yr I can't get sheep to drop my custom item. I've looked at multiple tutorials on doing this, but I still can't get it to work. I keep getting an error that says "RawLambChop cannot be resolved or is not a field." You can see where exactly I get this error below in the "Event Handler" spoiler. Any help would be much appreciated. My Code: Base Class package com.masterkulon.betterfood; import net.minecraft.item.ItemFood; import net.minecraft.item.ItemStack; import net.minecraftforge.common.MinecraftForge; import com.masterkulon.betterfood.help.Reference; import com.masterkulon.betterfood.help.RegisterHelper; import com.masterkulon.betterfood.items.ItemFoodCookedLambChop; import com.masterkulon.betterfood.items.ItemFoodRawLambChop; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.registry.GameRegistry; @Mod(modid = Reference.MODID, version = Reference.VERSION) public class BetterFood { public static ItemFood RawLambChop; public static ItemFood CookedLambChop; @EventHandler public void preInit(FMLPreInitializationEvent event) { RawLambChop = new ItemFoodRawLambChop(); RegisterHelper.registerItem(RawLambChop); //RegisterHelper simply registers the items CookedLambChop = new ItemFoodCookedLambChop(); RegisterHelper.registerItem(CookedLambChop); GameRegistry.addSmelting(RawLambChop, new ItemStack(CookedLambChop), 0.35F); } @EventHandler public void Init(FMLInitializationEvent event) { MinecraftForge.EVENT_BUS.register(new BetterFoodEventHandler()); } } Event Handler: package com.masterkulon.betterfood; import net.minecraft.entity.passive.EntitySheep; import net.minecraft.item.Item; import net.minecraftforge.event.entity.living.LivingDropsEvent; import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class BetterFoodEventHandler { @SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true) public void onEvent(LivingDropsEvent event) { if(event.entity instanceof EntitySheep) { event.entityLiving.dropItem(Item.RawLambChop.shiftedIndex, 1); //I get the error on "RawLambChop" here } } } Class for Raw Lamb Chop item: package com.masterkulon.betterfood.items; import com.masterkulon.betterfood.help.Reference; import net.minecraft.item.ItemFood; public class ItemFoodRawLambChop extends ItemFood { public ItemFoodRawLambChop() { super(3, 0.3F, true); setUnlocalizedName("rawLambChop"); setTextureName(Reference.MODID + ":" + getUnlocalizedName().substring(5)); } }
June 18, 201411 yr Hi. It looks like you might have been following my tutorial since my example there is sheep and uses similar coding style... Anyway, you can't use Item.RawLambChop because RawLambChop is not a field or method for the Item class. Instead I think you should have BetterFood.RawLambChop because you instantiated the raw lamb chop in your base class. Note that you should use Java naming convention and the field should be rawLambChop (lowercase initial "r"). Does that help? Check out my tutorials here: http://jabelarminecraft.blogspot.com/
June 18, 201411 yr Author It worked. Thank you very much! P.S. My coding style is actually derived from many different tutorials, but I may have seen yours among them all.
June 18, 201411 yr No problem, glad I could help. Check out my tutorials here: http://jabelarminecraft.blogspot.com/
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.