Jump to content
  • Home
  • Files
  • Docs
  • Merch
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.13] How to set HarvestLevel for a block?
1.13 Update Notes for Mod Creators
Sign in to follow this  
Followers 1
WARfree

[1.13] How to set HarvestLevel for a block?

By WARfree, April 11 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

WARfree    0

WARfree

WARfree    0

  • Tree Puncher
  • WARfree
  • Members
  • 0
  • 3 posts
Posted April 11

Hi, how can I set up harvetlevel  for a block?

  • Quote

Share this post


Link to post
Share on other sites

DavidM    104

DavidM

DavidM    104

  • World Shaper
  • DavidM
  • Members
  • 104
  • 1142 posts
Posted April 11 (edited)

Block#setHarvestLevel

Note that the first parameter is a string and specifies the tool type (i.e. "pickaxe", "shovel").

Override Block#getHarvestTool and Block#getHarvestLevel.

Edited April 11 by DavidM
  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6692

diesieben07

diesieben07    6692

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6692
  • 45730 posts
Posted April 11

Override getHarvestTool and getHarvestLevel in your block and return the appropriate values.

 

@DavidM That's for versions before 1.13.

  • Like 2
  • Quote

Share this post


Link to post
Share on other sites

WARfree    0

WARfree

WARfree    0

  • Tree Puncher
  • WARfree
  • Members
  • 0
  • 3 posts
Posted April 11
1 minute ago, diesieben07 said:

Override getHarvestTool and getHarvestLevel in your block and return the appropriate values.

 

@DavidM That's for versions before 1.13.

give me a exemple, please

  • Quote

Share this post


Link to post
Share on other sites

DavidM    104

DavidM

DavidM    104

  • World Shaper
  • DavidM
  • Members
  • 104
  • 1142 posts
Posted April 11 (edited)
8 minutes ago, WARfree said:

give me a exemple, please

Please check out the javadoc of the two methods:

/**
 * Queries the class of tool required to harvest this block, if null is returned
 * we assume that anything can harvest this block.
 */
ToolType getHarvestTool(IBlockState state);

/**
 * Queries the harvest level of this item stack for the specified tool class,
 * Returns -1 if this tool is not of the specified type
 *
 * @return Harvest level, or -1 if not the specified tool type.
 */
int getHarvestLevel(IBlockState state);

 

Note that the ToolType class contains some static final values like PICKAXE and AXE. You might want to use one of its values for the return type.

 

As for harvest levels:

- Wood: 0

- Stone: 1

- Iron: 2

- Diamond: 3

- Gold: 0

Edited April 11 by DavidM
  • Quote

Share this post


Link to post
Share on other sites

WARfree    0

WARfree

WARfree    0

  • Tree Puncher
  • WARfree
  • Members
  • 0
  • 3 posts
Posted April 11
20 minutes ago, DavidM said:

Please check out the javadoc of the two methods:


/**
 * Queries the class of tool required to harvest this block, if null is returned
 * we assume that anything can harvest this block.
 */
ToolType getHarvestTool(IBlockState state);

/**
 * Queries the harvest level of this item stack for the specified tool class,
 * Returns -1 if this tool is not of the specified type
 *
 * @return Harvest level, or -1 if not the specified tool type.
 */
int getHarvestLevel(IBlockState state);

 

Note that the ToolType class contains some static final values like PICKAXE and AXE. You might want to use one of its values for the return type.

 

As for harvest levels:

- Wood: 0

- Stone: 1

- Iron: 2

- Diamond: 3

- Gold: 0

I don't understand...

  • Quote

Share this post


Link to post
Share on other sites

Cadiboo    277

Cadiboo

Cadiboo    277

  • Reality Controller
  • Cadiboo
  • Members
  • 277
  • 3303 posts
Posted April 11
28 minutes ago, diesieben07 said:

Override getHarvestTool and getHarvestLevel in your block and return the appropriate values.

This means to override  those two methods and return the values you want (if you don't know how to override methods you need to learn basic Java). The two methods are 

24 minutes ago, DavidM said:

ToolType getHarvestTool(IBlockState state);

and

24 minutes ago, DavidM said:

int getHarvestLevel(IBlockState state);

 

You can use vanilla's pre-made ToolTypes such as

24 minutes ago, DavidM said:

PICKAXE and AXE

 

Harvest levels are

25 minutes ago, DavidM said:

- Wood: 0

- Stone: 1

- Iron: 2

- Diamond: 3

- Gold: 0

 

  • Quote

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

  • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 1
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • troyvs
      [1.12.2]help me to attach capability to player

      By troyvs · Posted 18 minutes ago

      please help me with attach capability to a player
    • troyvs
      [goto adder post duplicate ]help me to attach capability to player

      By troyvs · Posted 18 minutes ago

      please help me with attach capability to a player
    • martingabrixx
      CORAL TOMBSTONE MOD NOT WORKS

      By martingabrixx · Posted 56 minutes ago

      the mod of version 1.12.2 works in minecraft in individual mode but in my online server of 1.12.2 it doesn't work, could someone help me?
    • Oliviafrostpaw
      [1.14.4] Injecting into Existing Loot Tables, Blocks

      By Oliviafrostpaw · Posted 1 hour ago

      After some poking, the function is not firing whatsoever
    • RaphGamingz
      [1.14.4] Dimensions

      By RaphGamingz · Posted 2 hours ago

      Anyone?
  • Topics

    • troyvs
      0
      [1.12.2]help me to attach capability to player

      By troyvs
      Started 18 minutes ago

    • troyvs
      0
      [goto adder post duplicate ]help me to attach capability to player

      By troyvs
      Started 18 minutes ago

    • martingabrixx
      0
      CORAL TOMBSTONE MOD NOT WORKS

      By martingabrixx
      Started 56 minutes ago

    • Oliviafrostpaw
      7
      [1.14.4] Injecting into Existing Loot Tables, Blocks

      By Oliviafrostpaw
      Started December 8

    • RaphGamingz
      1
      [1.14.4] Dimensions

      By RaphGamingz
      Started Yesterday at 07:45 AM

  • Who's Online (See full list)

    • troyvs
    • prozed
    • Choco
    • ErdbeerbaerLP
    • nenikitov
    • ricoc90
    • Zimphire
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.13] How to set HarvestLevel for a block?
  • Theme
  • Contact Us
  • Discord

Copyright © 2019 ForgeDevelopment LLC · Ads by Curse Powered by Invision Community