53 lines
2.2 KiB
Java
53 lines
2.2 KiB
Java
package org.embeddedt.modernfix;
|
|
|
|
import net.minecraftforge.api.distmarker.Dist;
|
|
import net.minecraftforge.common.MinecraftForge;
|
|
import net.minecraftforge.event.server.ServerStartedEvent;
|
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
|
import net.minecraftforge.fml.DistExecutor;
|
|
import net.minecraftforge.fml.IExtensionPoint;
|
|
import net.minecraftforge.fml.ModLoadingContext;
|
|
import net.minecraftforge.fml.common.Mod;
|
|
import net.minecraftforge.fml.config.ModConfig;
|
|
import net.minecraftforge.fml.loading.FMLLoader;
|
|
import net.minecraftforge.network.NetworkConstants;
|
|
import org.apache.commons.lang3.tuple.Pair;
|
|
import org.apache.logging.log4j.LogManager;
|
|
import org.apache.logging.log4j.Logger;
|
|
import org.embeddedt.modernfix.core.config.ModernFixConfig;
|
|
|
|
import java.lang.management.ManagementFactory;
|
|
|
|
// The value here should match an entry in the META-INF/mods.toml file
|
|
@Mod(ModernFix.MODID)
|
|
public class ModernFix {
|
|
|
|
// Directly reference a log4j logger.
|
|
public static final Logger LOGGER = LogManager.getLogger("ModernFix");
|
|
|
|
public static final String MODID = "modernfix";
|
|
|
|
public static ModernFix INSTANCE;
|
|
|
|
// Used to skip computing the blockstate caches twice
|
|
public static boolean runningFirstInjection = false;
|
|
|
|
|
|
public ModernFix() {
|
|
INSTANCE = this;
|
|
// Register ourselves for server and other game events we are interested in
|
|
MinecraftForge.EVENT_BUS.register(this);
|
|
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> MinecraftForge.EVENT_BUS.register(new ModernFixClient()));
|
|
ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class, () -> new IExtensionPoint.DisplayTest(() -> NetworkConstants.IGNORESERVERONLY, (a, b) -> true));
|
|
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, ModernFixConfig.COMMON_CONFIG);
|
|
}
|
|
|
|
@SubscribeEvent
|
|
public void onServerStarted(ServerStartedEvent event) {
|
|
if(FMLLoader.getDist() == Dist.DEDICATED_SERVER) {
|
|
float gameStartTime = ManagementFactory.getRuntimeMXBean().getUptime() / 1000f;
|
|
ModernFix.LOGGER.warn("Dedicated server took " + gameStartTime + " seconds to load");
|
|
}
|
|
}
|
|
}
|