Jump to content

[SOLVED][1.8]Setting the harvest level in the constructer


2ShotKaos

Recommended Posts

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  :)

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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/

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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/

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.