Jump to content

Custom gamerule syncing [1.19.2] [SOLVED]


RInventor7

Recommended Posts

Hi! I have made a custom boolean gamerule. After restating the game though the gamerule is not synced between server and client. Am I registring my gamerule correctly? And how to sync it? Thanks.

@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
public class ModGameRules {
	
	public static final GameRules.Key<GameRules.BooleanValue> REAL_DAYLIGHT = GameRules.register("realDaylight", GameRules.Category.UPDATES, create(true));

	@SuppressWarnings("unchecked")
	public static Type<GameRules.BooleanValue> create(boolean defaultValue) {
		try {
			Method createGameruleMethod = ObfuscationReflectionHelper.findMethod(GameRules.BooleanValue.class, "m_46250_", boolean.class);
			createGameruleMethod.setAccessible(true);
			return (Type<GameRules.BooleanValue>) createGameruleMethod.invoke(GameRules.BooleanValue.class, defaultValue);
		} 
		catch (Exception e) { e.printStackTrace(); }
		return null;
	}
	
}

 

Edited by RInventor7
Link to comment
Share on other sites

GameRules are not automatically synched to the client. Most game rules are only for server side behaviour.

The only one I can see (from a quick check the of the ClientLevel class) vanilla sends to the client is RULE_DAYLIGHT which has its own special network packet.

See ClientBoundSetTimePacket which calls ClientLevel.setDayTime()

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

  • RInventor7 changed the title to Custom gamerule syncing [1.19.2] [SOLVED]

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.