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

Ok, so I need to change the vanilla properties of a few blocks:

 

1: Log blocks need to require an Axe to harvest (otherwise they drop nothing, like Stone). They also need to take longer to harvest. - I have tried calling setHardness and setHarvestLevel in preinit and the tools take longer and it does require a certain level tool to harvest, but it can still be harvested by hand.

 

2: Vanilla ore blocks (and other modded ores, specified by myself or a config file) which drop themselves need to instead drop an item, which is affected by Fortune (and will drop itself if harvested with Silk Touch). - I think I might be able to do this with Events, but if there is a better method please let me know.

 

3: The Furnace needs to be craftable but non-functional (cannot be right clicked, all Furnace recipes will be diverted elsewhere) - I would prefer it to not have a TileEntity, but if I cannot stop that then I can just cancel the event by hand.

 

4: Vanilla tools (and other modded tools, specified by myself or a config file) need to be craftable but non-functional. - I think this one may require actually changing the class of the tool, but I am uncertain. The replaced tools will act like they are Sticks in that they do not modify damage, attack speed, mining speed or harvest any blocks which cannot be harvested by hand.

 

5: (Somewhat unrelated) What is the best way to determine if something is food (IE: Can be eaten)? Do most mod creators who implement food extend ItemFood?

PlayerEvent.HarvestCheck

isn't fired for blocks with a

Material

that doesn't require a tool (e.g.

Material.WOOD

).

 

To make logs require a tool to harvest, you need to subscribe to

PlayerEvent.BreakSpeed

(to slow down the breaking) and

BlockEvent.HarvestDropsEvent

(to remove the drops).

 

I do something similar here, but this completely stops logs from being broken without the correct tool rather than just slowing it down and removing the drops.

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

PlayerEvent.HarvestCheck

isn't fired for blocks with a

Material

that doesn't require a tool (e.g.

Material.WOOD

).

 

To make logs require a tool to harvest, you need to subscribe to

PlayerEvent.BreakSpeed

(to slow down the breaking) and

BlockEvent.HarvestDropsEvent

(to remove the drops).

 

I do something similar here, but this completely stops logs from being broken without the correct tool rather than just slowing it down and removing the drops.

 

Ah - I had looked at PlayerEvent.HarvestCheck and found that it did not work on wood - is that a bug?

 

I didn't know about BlockEvent.HarvestDropsEvent, but that looks like it is what I am after.

  • Author

3: The Furnace needs to be craftable but non-functional (cannot be right clicked, all Furnace recipes will be diverted elsewhere) - I would prefer it to not have a TileEntity, but if I cannot stop that then I can just cancel the event by hand.

Cancel PlayerInteractEvent when right-clicking a furnace.

 

Is there an event which would allow me to stop the creation of a TileEntity when placing/loading a Furnace?

  • Author

4: Vanilla tools (and other modded tools, specified by myself or a config file) need to be craftable but non-functional. - I think this one may require actually changing the class of the tool, but I am uncertain. The replaced tools will act like they are Sticks in that they do not modify damage, attack speed, mining speed or harvest any blocks which cannot be harvested by hand.

You can change this again using PlayerEvent.HarvestCheck and possibly PlayerEvent.BreakSpeed (may not be necessary).

 

What about attack damage/speed? How do I remove those?

 

Edit: Also, PlayerEvent.HarvestCheck does not fire when mining ore blocks.

 

Edit 2: I will look to see if my forge is out-of-date. If it is, what is the method for updating the forge version?

  • Author

Ok, on the latest version PlayerEvent.HarvestCheck does not fire if you have a proper tool equipped, which means I cannot prevent a tool from working.

Now I just need to remove tool durability and the changes to attack damage/speed.

 

Use

Item#setMaxDamage

to set the maximum damage of an item.

 

To stop an item from providing

AttributeModifier

s, you can set the

"AttributeModifiers"

key of the

ItemStack

's compound tag to an empty list tag. You'll probably want to do this in either

LivingUpdateEvent

(to affect all living entities) or

PlayerTickEvent

(to affect players). You can probably just modify the entity's held items and not worry about their inventory.

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.

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.