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

Wouldn't overriding a hoe work well in your case?

If anyone has a comprehensive, visual guide to GUIs - don't hesitate to message me. They make my head spin.

  • Author

Wouldn't overriding a hoe work well in your case?

 

yes but I really want to do more with it, and create other tools such as hammers, wrenches, etc

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.

  • Author

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

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.

Create a normal item an override canharvestblock in your item. Create a private float wich will be the efficiency of the tool and override func_150893_a and return the private efficiency float. Use onitemuse do create the rocks and stuff you wanted.

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.