Jump to content

setHarvestLevel


Kander16

Recommended Posts

Ok, I have tried to work it out. But I can only mine the blocks with my pickaxe. Not the shovel

 

This is my code:

 

    @Override

    public int getHarvestLevel(int metadata)

    {

    if (this == Chef.oreSaltOre) {

    this.setHarvestLevel("pickaxe", 2);

    } else if (this == Chef.oreSaltOre2) {

    this.setHarvestLevel("shovel", 1);

    }

return metadata;

    }

 

 

Creator of the Master Chef Mod and many more to come.

 

If I helped you, please click the 'thank you' button.

Link to comment
Share on other sites

For the level to harvest it, Something like this?

 

    @Override
    public int getHarvestLevel(int metadata)
    {
    	if (this == Chef.oreSaltOre) {
    		this.getHarvestLevel(2);
    	} else if (this == Chef.oreSaltOre2) {
    		this.getHarvestLevel(1);
    	}
	return getHarvestLevel(0);
    }

Creator of the Master Chef Mod and many more to come.

 

If I helped you, please click the 'thank you' button.

Link to comment
Share on other sites

G'Day

 

No I'd rather check the metadata, since this is surely passed to the method.

 

Use somewhere mostly defined an array of IIcons or something, where you decode the metadata into the corresponding IIcon, right?

Do the same in here: depending on the metadata return a different harvestlevel.

 

I hope this brought you to the right direction.

Sincerely -pick

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.

Link to comment
Share on other sites

G'Day

 

It looks like I see why you're so confused.

Metadata is a number that a block can have, as an attribute. The best known example is wool: the color is a 'visual representation' of that metadata (from the coding view it's vice versa).

 

You should calculate or _return_ the harvest level more or less the same why like you did it with the IIcons.

 

-> EDIT: As diesieben07 previously mentioned: _return_ is the keyword you are looking for.

 

But to be honestly, it looks like you really recently started modding and I'd really suggest to go to google and read through / look some tutorials.

 

Sincerely -pick

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.

Link to comment
Share on other sites

Yes, your right.

Maybe I should look for tutorials.

But can you give an example?

Then I am gonna try to understand what it means.

 

After that, I AM gonna look for some tutorials on google.  :)

 

Thanks for helping.

 

~Rob

 

Creator of the Master Chef Mod and many more to come.

 

If I helped you, please click the 'thank you' button.

Link to comment
Share on other sites

Yes, your right.

Maybe I should look for tutorials.

But can you give an example?

Then I am gonna try to understand what it means.

 

After that, I AM gonna look for some tutorials on google.  :)

 

Thanks for helping.

 

~Rob

If you have to search for tutorials for this type of very basic Java, you shouldn't be modding. Learn Java and come back then.

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

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.