Jump to content

Recommended Posts

Posted

I've been enjoying my dive into Forge modding so far, but I'm being presented with a pretty steep compatability conundrum at the moment. (I'm interested in general best practices and solutions, not just this specific case, but to make explaining it easier, I'm just going to talk about my current specific scenario rather than try to generalize.)

My current end-goal here is bee hibernation: if the temperature at the hive's location is below freezing, then the bees won't come out. For my own hives, this is a trivial modification, since they already use mod classes that extend vanilla and I can override methods there with impunity. But this does Absolutely Nothing for the vanilla bee nests.

The obvious solution is to replace all the vanilla bee nests with my own modded version as well, but that raises potential compatability issues if there's ever a different hypothetical mod that also wants to extend beehive functionality. I'd likely have to write in compatability with other mods on a case-by-case basis.

(The only other thing I've stumbled across is coremods and I am absolutely not going to touch core modding. xD If I can't do a thing without coremodding I am simply not going to do it.)

So, that said: what should I be doing here? Is replacing the vanilla entities with modded extensions typical, or is there a better solution?

Posted

there is no definite answer.

for your case - bees - you need to investigate bee entity and bee hive and see what code is where.

investigate bee goals (or ai tasks). goals can be replaced with your own. or, maybe instead of removing original goal for finding flowers, you can just add your own and bee will sometimes use original code and sometimes your code for finding flowers.

and there are always events - when a bee entity is about to be spawned, you can decide you don't want that. store all the bee's data and cancel it being added to the world. then later (when it gets warmer or whatever), take the bees you stored and add them to the world yourself (when you deserialize their data, they'll know their hive location).... events can do wonders, but onlyu after you looked into the flow of original code.

Posted
8 hours ago, diesieben07 said:

If there are no hooks in place for what you want to do, you can go down several routes.

  • Make a pull request into Forge if you think the hook could be useful for others as well.
  • Replace the vanilla objects
  • Just not alter vanilla things

Ah, hmm! I hadn't thought about adding a hook to Forge myself. I'll have to sit down and go through everything to figure out if there's a most generally useful approach that could use a new hook.

 

7 hours ago, MFMods said:

there is no definite answer.

for your case - bees - you need to investigate bee entity and bee hive and see what code is where.

investigate bee goals (or ai tasks). goals can be replaced with your own. or, maybe instead of removing original goal for finding flowers, you can just add your own and bee will sometimes use original code and sometimes your code for finding flowers.

and there are always events - when a bee entity is about to be spawned, you can decide you don't want that. store all the bee's data and cancel it being added to the world. then later (when it gets warmer or whatever), take the bees you stored and add them to the world yourself (when you deserialize their data, they'll know their hive location).... events can do wonders, but onlyu after you looked into the flow of original code.

I've already done all those things, but it's a good reminder to look at the original source. (Speaking of flow of original code, the changes I want to make are on the TileEntity for the hive, not the bee, but that's tangential.)

Although, when I was investigating the bee-goals angle, I couldn't find an easy way to replace or add AI goals without writing your own custom extension class? I don't need it for this, but if there's a hook for that, I'd love to learn what it is.

Posted (edited)

So to summarize, it sounds like if I have a specific change in mind, the first step is to make absolutely sure there are no existing hooks that can do the thing, and then, if it's likely enough other people will want to modify the thing themselves to cause inter-mod compatability issues, I should look into making a forge hook PR everyone can use, and if it's not likely, then I don't really need to worry about it and can just replace them. Which is extremely reasonable.

p.s. Thanks to going back and reviewing all the stuff that is in Forge already, I think I got a solution involving cancelling the bee entity join event and re-adding the bee data to the hive as an alternative to changing the release conditions, so I shouldn't have to break into anything after all. It's kinda tricky to find the stuff I need to use as a fresh modder but I'm continually impressed by how Forge is put together to let you do stuff.

Edited by InspectorCaracal
added postscript
Posted

This has nothing to do with the OP but it's a direct result of my previous post and I hate how I keep making new threads so I'm reusing this one >.>

I'm trying to implement my entity join event solution, but I'm stuck because I can't figure out how to check if a chunk is fully loaded or not. My searching turned up exactly one solution, which is for 1.14 and references World.getChunkProvider().isChunkLoaded(pos) - which doesn't appear to exist in 1.16

How do I check if a chunk is fully loaded in 1.16.x?

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.