Jump to content

[1.8] Custom Tool Help


statphantom

Recommended Posts

I am trying to make a custom tool, but am unsure how to do this, by custom I mean custom custom, only effective on certain blocks with durability etc, without extending pickaxe / shovel etc.

 

how do I go about doing this, do I still need ToolMaterial? should I extend one of the tool classes but override everything? any help is appreciated.

 

thanks.

 

 

PS: I am trying to make a 'rake' tool that when you click on a grass block with it it will gather a few sticks, rocks, etc. and then loose durability, but also has damage against entities etc.

Link to comment
Share on other sites

Extend

ItemTool

and call

setHarvestLevel("someCustomToolClass", toolMaterial.getHarvestLevel())

in the constructor. As long as the

ItemTool#toolClass

field is

null

(which it will be if you extend

ItemTool

directly), 

getHarvestLevel

and

getToolClasses

will return the result of the super methods (which use the values set by

Item#setHarvestLevel

).

 

You can then call

Block#setHarvestLevel

with the same tool class to allow a block to be harvested by that tool.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Extend

ItemTool

and call

setHarvestLevel("someCustomToolClass", toolMaterial.getHarvestLevel())

in the constructor. As long as the

ItemTool#toolClass

field is

null

(which it will be if you extend

ItemTool

directly), 

getHarvestLevel

and

getToolClasses

will return the result of the super methods (which use the values set by

Item#setHarvestLevel

).

 

You can then call

Block#setHarvestLevel

with the same tool class to allow a block to be harvested by that tool.

 

the super constructor needs a float, an enum, and a set. for the float, damage i just put 2.0f, but for the enum I put EnumHelper.addToolMaterial("woodenrake", 0, 31, 0f, 2f, 2); and for the set, I put null (does that just mean none set)?

Link to comment
Share on other sites

the super constructor needs a float, an enum, and a set. for the float, damage i just put 2.0f, but for the enum I put EnumHelper.addToolMaterial("woodenrake", 0, 31, 0f, 2f, 2); and for the set, I put null (does that just mean none set)?

 

You should create the

ToolMaterial

once (probably in the same class where you instantiate and register your items, just before you do that) and then reference it for your tools. Multiple tools can share a

ToolMaterial

(e.g. all vanilla wooden tools use

ToolMaterial.WOOD

). You can also just use an existing

ToolMaterial

.

 

The

Set

is the

Block

s that the tool is effective against, but Forge replaces that with the harvest level system so it's not actually used unless some mod decides to ignore Forge's system and use the vanilla system. Just in case, you should pass an empty

Set

(just create a new

HashSet

) instead of

null

; that way the vanilla system won't crash with a

NullPointerException

.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

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.