Jump to content

[1.9] Changing Vanilla Block/Item Properties


Notunknown

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

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.