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

Posted

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.

  • 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.

  • 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.

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.

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?

 

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.

  • 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.

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.