Jump to content

Recommended Posts

Posted

Is there a way to add functionality to vanilla blocks, e.g. I am working on a mod that adds weeds that destroy your crops. I want there to be a random chance that everytime a crop grows it can turn into weeds that spread to nearby crops over time. For that I would have to change the tick function of existing block classes. Is there an easy way to do this?

Posted (edited)

Hm, maybe I don't need to edit vanilla blocks if there's an event that fires when crops grow? Is there such an event? This is in Forge 1.13.2 btw

Edited by Yamahari
Posted

CropGrowEvent

 

I don't know if its been added to the 1.13 codebase yet, but I added it to 1.12 a while back, so it should get moved forward soon, if it hasn't been already.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted (edited)

Yes! That worked just fine. I subscribed to CropGrowEvent.Post and now my weeds spread like wildfire x) 

The problem now arises at a different point though. I want to change the way bonemeal works, but I can't edit the ItemBoneMeal class. Would it be best to make my own custom BoneMeal class and place that in all the recipes where normal bonemeal would needed? Or is there a way simpler way I am missing. 

Edited by Yamahari
Posted

Well there's also a BoneMealEvent event x) and my next question would have been how I can change the functionality of the Hoe, but who would have thought, there is an UseHoeEvent! 

Posted (edited)

If you need to modify the behavior of a vanilla Item/Block, you could also create your own version of the Item/Block and replace the vanilla one with it.

This might be useful if there is no event for the behavior you would like to modify.

An example of this is done in FastWorkbench, where the author created a new crafting table and replaced the vanilla one with it.

Edited by DavidM

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Posted

You might also want to check out my farming mod:

https://github.com/Draco18s/ReasonableRealism/tree/1.12.1/src/main/java/com/draco18s/farming

Code is still 1.12, but everything should still be possible. I did weeds and bonemeal and hoe modifications too.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
6 hours ago, DavidM said:

If you need to modify the behavior of a vanilla Item/Block, you could also create your own version of the Item/Block and replace the vanilla one with it.

This might be useful if there is no event for the behavior you would like to modify.

An example of this is done in FastWorkbench, where the author created a new crafting table and replaced the vanilla one with it.

Is replacing vanilla blocks and items considered good practice?

5 hours ago, Draco18s said:

You might also want to check out my farming mod:

https://github.com/Draco18s/ReasonableRealism/tree/1.12.1/src/main/java/com/draco18s/farming

Code is still 1.12, but everything should still be possible. I did weeds and bonemeal and hoe modifications too.

I like the way you did the spreading of weeds ! But my plan with bonemeal is to make it impossible to use on crops. You now have to bonemeal the ground before you can plant anything, basically adding a nutrition property to farmland that gets removed once a crop on it has grown to max age.

Posted
9 hours ago, DavidM said:

If you need to modify the behavior of a vanilla Item/Block, you could also create your own version of the Item/Block and replace the vanilla one with it.

This might be useful if there is no event for the behavior you would like to modify.

An example of this is done in FastWorkbench, where the author created a new crafting table and replaced the vanilla one with it.

It seems like you can no longer do that in 1.13.2, I get runtime exception with the message "Illegal replacement of vanilla ... "

Posted
7 hours ago, Yamahari said:

I like the way you did the spreading of weeds ! But my plan with bonemeal is to make it impossible to use on crops. You now have to bonemeal the ground before you can plant anything, basically adding a nutrition property to farmland that gets removed once a crop on it has grown to max age.

Its been a long time, but I was pretty sure I messed with bonemeal use too, but I can't find it now.

You should still be able to hook into the Bonemeal events and cancel it, preventing their usage on crops.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Replacing vanilla blocks is sometimes necessary if there's no event that will let you achieve the behavior you want. It can decrease mod compatibility if other mods are modifying or replacing the same block as you, so try to use events first.

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.