Posted October 27, 20177 yr Hello. I'm starting this mod for testing. I was reading that executing commands with ICommandManager is a bad practice. My mod does only one thing, slower the timer (increasing day/night length). It's actually working. But I have some questions... Is there a better way to stop the game timer and change it manually instead of execute the game command? When I run the the mod on a server, or just "open lan", I start to see tons of "Server: Added 1 to the time". Is there a way to prevent that? Spoiler @Mod.EventBusSubscriber public class Events { public static boolean isSet = false; public static int tickCounter = 0; @SubscribeEvent public static void onTick(TickEvent.WorldTickEvent event) { tickCounter++; if (tickCounter < 70) return; try { tickCounter = 0; if (event == null) return; World world = event.world; if (world == null) return; execCommand(world, "/time add 1"); }catch(Exception ex) { System.out.println("swn => event [onTick] fail!"); System.out.println(" " + ex.getMessage()); } } @SubscribeEvent public static void onWorldLoaded(WorldEvent.Load event) { try { if (isSet) return; if (event == null) return; World world = event.getWorld(); if (world == null) return; execCommand(world, "/gamerule doDaylightCycle false"); }catch(Exception ex) { System.out.println("swn => event [onWorldLoaded] fail!"); System.out.println(" " + ex.getMessage()); } } private static void execCommand(World world, String command) { if (world.provider.getDimension() != 0) return; if (world.isRemote) return; MinecraftServer server = world.getMinecraftServer(); ICommandManager cmd = server.getCommandManager(); cmd.executeCommand(server, command); } } Edited October 27, 20177 yr by sworn
October 27, 20177 yr To quote myself from a similar post On 2017-04-01 at 0:17 PM, Matryoshika said: You need to create a custom WorldProvider, and override calculateCelestialAngle. Then you need to register said WorldProvider to the wanted dimension(s), by calling DimensionManager#unregisterDimension(id) and then re-registering it with DimensionManager#registerDimension(id, DimensionType#register(...)) Though I would iterate over the worlds, and check their WorldProvider's first, and only change if the WorldProvider is an instanceof the overworld's WorldProvider, as some dimensions have "frozen" time, etc. calculateCelestialAngle is the method Minecraft uses to figure out time for the WorldProvider's associated dimension. If you override it, you can make it state whatever time you want. Edited October 27, 20177 yr by Matryoshika Also previously known as eAndPi. "Pi, is there a station coming up where we can board your train of thought?" -Kronnn Published Mods: Underworld Handy links: Vic_'s Forge events Own WIP Tutorials.
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.