This site works best with JavaScript enabled. Please enable JavaScript to get the best experience from this site.
Gamerules are really useful and can effect gameplay in many ways, and are really easy to use.
Making gamerules are however might be hard to do if you don't know where to start.
Step 1: make the FMLServerStartingEvent in your @Mod class
@EventHandler public void serverStart(FMLServerStartingEvent event) {}
this is called when you open your world(Single Player) or opening your server(Multiplayer)
this event is also used to make commands (Look It Up)
Step 2: use the event variable to get the world
World world = event.getServer().getEntityWorld();
Step 3: If you've ever messed around with the World class and/or have messed around with gamerules in code before
you should know what to do.
world.getGameRules().setOrCreateGameRule("<your gamerule name>", "<value>");
You can use this again to set the value.
Full Code:
@EventHandler public void serverStart(FMLServerStartingEvent event) { World world = event.getServer().getEntityWorld(); world.getGameRules().setOrCreateGameRule("", ""); }
Now You're Done!
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumGamerules are really useful and can effect gameplay in many ways, and are really easy to use.
Making gamerules are however might be hard to do if you don't know where to start.
Step 1: make the FMLServerStartingEvent in your @Mod class
@EventHandler public void serverStart(FMLServerStartingEvent event) {}this is called when you open your world(Single Player) or opening your server(Multiplayer)
this event is also used to make commands (Look It Up)
Step 2: use the event variable to get the world
Step 3: If you've ever messed around with the World class and/or have messed around with gamerules in code before
you should know what to do.
world.getGameRules().setOrCreateGameRule("<your gamerule name>", "<value>");You can use this again to set the value.
Full Code:
@EventHandler public void serverStart(FMLServerStartingEvent event) { World world = event.getServer().getEntityWorld(); world.getGameRules().setOrCreateGameRule("", ""); }Now You're Done!
My mods
#StopModReposts