Posted December 25, 201410 yr Hello, I was wondering how i could make a new food (corn) that allows you to place the block to (like ItemSeedFood) but then with a sort of reed. Thanks. Creator of the Master Chef Mod and many more to come. If I helped you, please click the 'thank you' button.
December 25, 201410 yr Author Yes, But ItemReed is an Item, not ItemFood I was trying to let it extends ItemFood, not Item anymore but then i am having trouble with the constructor. Creator of the Master Chef Mod and many more to come. If I helped you, please click the 'thank you' button.
December 25, 201410 yr Author Ok, So i wanted to create a new crop that works like a sugar cane (corn). With a sugar cane plant, you collect the sugar cane, but you cannot eat them. I want to have a corn plant, that gives you the items of it. You can use it for planting another corn, or you could eat it as well. Now, the problem is that a sugar cane item extends Item, not Itemfood. And i can't get it to work. Cause when iam trying to plant the corn. It just crashes the whole game. This is my code: http://pastebin.com/V53FNAj1 Thanks. Creator of the Master Chef Mod and many more to come. If I helped you, please click the 'thank you' button.
December 25, 201410 yr Hi I bet your 'crash' is a _NullPointerException_. The way how you set up the class and (I assume, since you only provided us with one file) your block / item registration works, your block flied is null on run time. Don't use object variables if you try to do something like this! I'd suggest to directly access your mod blocks within the onItemUse method. Sincerely -pick. PS: you CAN rename class / object variables within your own class, this technique makes code more readable Since English is not my mother tongue, my sentences may are confusing. I'm coding java for a long time now - just MC and forge stop me sometimes.
December 25, 201410 yr Author This is what I got, http://pastebin.com/AAfqBgW5 Creator of the Master Chef Mod and many more to come. If I helped you, please click the 'thank you' button.
December 25, 201410 yr Well, I aint 100% sure what ur trying to do You want the item to be eatable and working like a seed: extend ItemSeedFood only eatable: extend ItemFood only seed: extend ItemSeeds Or is that not the problem at all?
December 25, 201410 yr Hi Did you test my previous advice? The crash-report really looks like the above mentioned problem occured. If it helps: //within your onItemUse //do stoff world.setBlock(x,y+1,z, ModBlocks.YOURCORN, 0, flag); //y+1 since you mostly want to place the corn _above_ the clicked block //ModBlocks.YOURCORN, thats the mod-unique field of the desired block //0 - I assume this is the first growth stage (or generally: the metadata) //flag, an integer flag. see World.setBlock(int,int,int,Block,int,int) to get more info about that //do other stuff like reduce itemstack and so on... Sincerely -pick PS: Why didn't you post your new code? Since English is not my mother tongue, my sentences may are confusing. I'm coding java for a long time now - just MC and forge stop me sometimes.
December 26, 201410 yr Author Thank you. This actually works! Creator of the Master Chef Mod and many more to come. If I helped you, please click the 'thank you' button.
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.