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

I was wondering if someone can tell me how to the the harvest level (.setHarvestLevel("pickaxe",2)) in the constructer because it always seems to give me an error. Some sample code would help. Here is what i have.

 

marble = new Block(Material.rock).setUnlocalizedName("marble").setCreativeTab(MoarMinecraft.tabMM).setHardness(1).setStepSound(Block.soundTypeStone); Thanks  :)

 

And the error msg is???

 

Also: Why are you instantiating a new Block instead of something like BlockMarble? Don't you have a unique subclass for this new type of block? With a unique subclass, its constructor could set harvest level (and other properties).

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

You can't include

setHarvestLevel

in your 'chain', as that method doesn't have a Block as it's return type. You have to call

setHarvestLevel

after your block instantiation.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

  • Author

And the error MSG is???

 

Also: Why are you instantiating a new Block instead of something like BlockMarble? Don't you have a unique subclass for this new type of block? With a unique subclass, its constructor could set harvest level (and other properties).

 

I actually am not using separate classes for all the blocks, is that a better way? Seems more organized. I have one huge mod page with all my blocks and one for items. Then the main mod class. I could set it after the game registry but I don; like that. Should I just start over with each class for one block?

No, I meant it like this:

marble = new Block().whatevermethodsyouwant();

marble.setHarvestLevel(parameters);

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

  • Author

No, I meant it like this:

marble = new Block().whatevermethodsyouwant();

marble.setHarvestLevel(parameters);

 

Would it still be better to make a separate class for each block/Item?

Would it still be better to make a separate class for each block/Item?

I just looked at where vanilla MC makes its blocks, and none instantiate the parent Block class. I suspect that when you get to defining your marble's behavior, you'll want to override something, so you may as well start by subclassing Block or something like BlockStone (which would let you inherit stone material and behavior).

 

Then you may set the harvest level either inside your constructor or after instantiation (inside is the natural place for such a property setting).

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

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.