Jump to content

[1.16.5] Is there a way to be notified of changes to a gamerule?


Recommended Posts

Posted

This is probably impossible, but figured I'd check just in case.  I am working on a mod which automatically changes the values of some game rules, or more specifically "disables" specific rules if certain conditions are met.
However, if someone changes the value of a game rule, say doDaylightCycle from false to true after my mod disables it then when my mod's status is triggered to update it thinks the rule is currently disabled.  I mean obviously
setting doDaylightCycle back to true won't change anything since the user already changed it to true, but this is different for a game rule like randomTickSpeed where the value is non-binary.

With randomTickSpeed, however, when I say "disabled" that means set to 0.  When I disable it, I store the current value so I can restore it later.  However, the user can update the randomTickSpeed to something else.
That's okay because I can check the current value when my mod goes to update and make sure I store the new value if it has changed.  But, the user could explicitly update the game rule value of randomTickSpeed to 0
and expect that when my mod re-enables randomTickSpeed that the value remains 0.  There is no way for me to know they specifically set it to 0.


Not sure if there is anything in Forge that allows me to subscribe to changes in the game rules or something like that.  Otherwise I guess that workflow just can't work with my mod.
I guess a way I could do it is to have my own commands which set the "enabled" values for the game rules, but I would prefer an automatic behind the scenes solution.

Posted (edited)

I've been able to get it working, so thank you.  However, I still don't quite understand how to use the discord bot to find the SRG name of the field GameRules.RuleType.callback.

I managed to find it with !moj callback, but how would I have searched for callback on GameRules.RuleType specifically?  I also don't understand the different between !moj and !mcp

Edited by Gr3atsaga

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.