mirror of
				https://github.com/SquidDev-CC/CC-Tweaked
				synced 2025-10-31 05:33:00 +00:00 
			
		
		
		
	Minor improvements to resetting code
- Reset state while the server is starting rather than once it has started. Hopefully fixes a weird issue where wireless modems wouldn't be "connected" on server startup. - Correctly reset the MainThread metrics on server start/stop.
This commit is contained in:
		| @@ -23,8 +23,8 @@ import java.util.concurrent.atomic.AtomicLong; | ||||
|  * {@link MainThread} starts cool, and runs as many tasks as it can in the current {@link #budget}ns. Any external tasks | ||||
|  * (those run by tile entities, etc...) will also consume the budget | ||||
|  * | ||||
|  * Next tick, we put {@link ComputerCraft#maxMainGlobalTime} into our budget (and clamp it to that value to). If we're | ||||
|  * still over budget, then we should not execute <em>any</em> work (either as part of {@link MainThread} or externally). | ||||
|  * Next tick, we add {@link ComputerCraft#maxMainGlobalTime} to our budget (clamp it to that value too). If we're still | ||||
|  * over budget, then we should not execute <em>any</em> work (either as part of {@link MainThread} or externally). | ||||
|  */ | ||||
| public final class MainThread | ||||
| { | ||||
|   | ||||
| @@ -29,7 +29,6 @@ import net.minecraftforge.event.*; | ||||
| import net.minecraftforge.event.entity.player.PlayerContainerEvent; | ||||
| import net.minecraftforge.eventbus.api.SubscribeEvent; | ||||
| import net.minecraftforge.fml.common.Mod; | ||||
| import net.minecraftforge.fml.event.server.FMLServerStartedEvent; | ||||
| import net.minecraftforge.fml.event.server.FMLServerStartingEvent; | ||||
| import net.minecraftforge.fml.event.server.FMLServerStoppedEvent; | ||||
| 
 | ||||
| @@ -90,22 +89,21 @@ public final class CommonHooks | ||||
|         { | ||||
|             ComputerMBean.register(); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     @SubscribeEvent | ||||
|     public static void onServerStarted( FMLServerStartedEvent event ) | ||||
|     { | ||||
|         ComputerCraft.serverComputerRegistry.reset(); | ||||
|         WirelessNetwork.resetNetworks(); | ||||
|         Tracking.reset(); | ||||
|         resetState(); | ||||
|         ComputerMBean.registerTracker(); | ||||
|         NetworkUtils.reset(); | ||||
|     } | ||||
| 
 | ||||
|     @SubscribeEvent | ||||
|     public static void onServerStopped( FMLServerStoppedEvent event ) | ||||
|     { | ||||
|         resetState(); | ||||
|     } | ||||
| 
 | ||||
|     private static void resetState() | ||||
|     { | ||||
|         ComputerCraft.serverComputerRegistry.reset(); | ||||
|         MainThread.reset(); | ||||
|         WirelessNetwork.resetNetworks(); | ||||
|         Tracking.reset(); | ||||
|         NetworkUtils.reset(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Jonathan Coates
					Jonathan Coates