Java Code Examples for net.minecraftforge.fml.common.Mod

The following examples show how to use net.minecraftforge.fml.common.Mod. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: SkyblockAddons   Source File: SkyblockAddons.java    License: MIT License 6 votes vote down vote up
@Mod.EventHandler
public void init(FMLInitializationEvent e) {
    MinecraftForge.EVENT_BUS.register(new NetworkListener());
    MinecraftForge.EVENT_BUS.register(playerListener);
    MinecraftForge.EVENT_BUS.register(guiScreenListener);
    MinecraftForge.EVENT_BUS.register(renderListener);
    MinecraftForge.EVENT_BUS.register(scheduler);
    MinecraftForge.EVENT_BUS.register(newScheduler);

    ClientCommandHandler.instance.registerCommand(new SkyblockAddonsCommand());

    addKeybinds(new SkyblockKeyBinding("open_settings", Keyboard.KEY_NONE, Message.SETTING_SETTINGS),
            new SkyblockKeyBinding( "edit_gui", Keyboard.KEY_NONE, Message.SETTING_EDIT_LOCATIONS),
            new SkyblockKeyBinding( "lock_slot", Keyboard.KEY_L, Message.SETTING_LOCK_SLOT),
            new SkyblockKeyBinding( "freeze_backpack", Keyboard.KEY_F, Message.SETTING_FREEZE_BACKPACK_PREVIEW));
}
 
Example 2
Source Project: I18nUpdateMod   Source File: I18nUpdateMod.java    License: MIT License 6 votes vote down vote up
@Mod.EventHandler
public void init(FMLInitializationEvent event) {
    // 国际化检查
    if (I18nConfig.internationalization.openI18n && !isChinese()) {
        return;
    }

    // 命令注册
    ClientCommandHandler.instance.registerCommand(new CmdNotice());
    ClientCommandHandler.instance.registerCommand(new CmdReport());
    ClientCommandHandler.instance.registerCommand(new CmdReload());
    ClientCommandHandler.instance.registerCommand(new CmdGetLangpack());
    ClientCommandHandler.instance.registerCommand(new CmdUpload());
    ClientCommandHandler.instance.registerCommand(new CmdToken());

    // 热键注册
    if (!I18nConfig.key.closedKey) {
        MinecraftForge.EVENT_BUS.register(new HotKeyHandler());
    }
}
 
Example 3
Source Project: GT-Classic   Source File: GTMod.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
@Mod.EventHandler
public synchronized void preInit(FMLPreInitializationEvent event) {
	logger = event.getModLog();
	proxy.preInit(event);
	logger.info("Hello from GregTech Classic!");
	GTBlocks.registerTiles();
	GTMaterialGen.initFlags();
	GTMaterialGen.init();
	GTBlocks.registerBlocks();
	GTItems.initItems();
	GTItems.registerItems();
	GTCrops.init();
	GTOreDict.init();
	GTEventLootTableLoad.init();
	MinecraftForge.EVENT_BUS.register(GTSounds.class);
}
 
Example 4
Source Project: BakaDanmaku   Source File: BakaDanmaku.java    License: MIT License 6 votes vote down vote up
@Mod.EventHandler
public void init(FMLInitializationEvent event) {
    // 装载各大平台的弹幕线程
    DanmakuThreadFactory.setDanmakuThread("bilibili", new BilibiliDanmakuThread());
    DanmakuThreadFactory.setDanmakuThread("douyu", new DouyuDanmakuThread());
    DanmakuThreadFactory.setDanmakuThread("chushou", new ChushouDanmakuThread());

    // 注册开启,关闭弹幕事件处理器
    MinecraftForge.EVENT_BUS.register(StartStopHandler.class);

    // 注册聊天事件处理器
    MinecraftForge.EVENT_BUS.register(ChatMsgHandler.class);

    // 注册屏幕信息事件处理器
    // TODO: MinecraftForge.EVENT_BUS.register(ScreenMsgHandler.class);

    // 客户端命令注册
    ClientCommandHandler.instance.registerCommand(new CommandBakaDM());
}
 
Example 5
@Mod.EventHandler
public void init(FMLInitializationEvent evt) {
	try {
		proxy.init(evt);
		nativeConverters.stream().forEachOrdered(forgeLoadable -> forgeLoadable.init(evt));
		int size = novaModWrappers.size() + novaWrappers.size();
		if (size > 0) {
			ProgressManager.ProgressBar progressBar = ProgressManager.push("Initializing NOVA wrappers", size);
			FMLProgressBar fmlProgressBar = new FMLProgressBar(progressBar);
			novaModWrappers.stream().forEachOrdered(wrapper -> {
				fmlProgressBar.step(wrapper.getClass());
				wrapper.init(evt);
			});
			novaWrappers.stream().forEachOrdered(wrapper -> {
				fmlProgressBar.step(wrapper.getClass());
				wrapper.init(evt);
			});
			fmlProgressBar.finish();
			ProgressManager.pop(progressBar);
		}
	} catch (Exception e) {
		Game.logger().error("Error during init");
		e.printStackTrace();
		throw new InitializationException(e);
	}
}
 
Example 6
Source Project: SkyblockAddons   Source File: SkyblockAddons.java    License: MIT License 5 votes vote down vote up
@Mod.EventHandler
public void postInit(FMLPostInitializationEvent e) {
    onlineData = new Gson().fromJson(new JsonReader(utils.getBufferedReader("data.json")), OnlineData.class);
    configValues.loadValues();
    persistentValues.loadValues();

    setKeyBindingDescriptions();

    usingLabymod = utils.isModLoaded("labymod");
    usingOofModv1 = utils.isModLoaded("refractionoof", "1.0");

    utils.pullOnlineData();
    scheduleMagmaBossCheck();

    for (Feature feature : Feature.values()) {
        if (feature.isGuiFeature()) feature.getSettings().add(EnumUtils.FeatureSetting.GUI_SCALE);
        if (feature.isColorFeature()) feature.getSettings().add(EnumUtils.FeatureSetting.COLOR);
    }

    if (configValues.isEnabled(Feature.FANCY_WARP_MENU)) {
        // Load in these textures so they don't lag the user loading them in later...
        for (IslandWarpGui.Island island : IslandWarpGui.Island.values()) {
            Minecraft.getMinecraft().getTextureManager().bindTexture(island.getResourceLocation());
        }
    }
    Minecraft.getMinecraft().getTextureManager().bindTexture(SkyblockAddonsGui.LOGO);
    Minecraft.getMinecraft().getTextureManager().bindTexture(SkyblockAddonsGui.LOGO_GLOW);
}
 
Example 7
Source Project: I18nUpdateMod   Source File: I18nUpdateMod.java    License: MIT License 5 votes vote down vote up
@Mod.EventHandler
public void construct(FMLConstructionEvent event) {
    // 国际化检查
    if (I18nConfig.internationalization.openI18n && !isChinese()) {
        return;
    }

    DownloadInfoHelper.init();

    // 设置中文
    if (I18nConfig.download.setupChinese) {
        setupLang();
    }

    if (!I18nConfig.download.shouldDownload) {
        return;
    }

    ResourcePackBuilder builder = new ResourcePackBuilder();
    boolean needUpdate = builder.checkUpdate();
    ResourcePackInstaller.setResourcesRepository();

    if (needUpdate) {
        String localPath;
        try {
            localPath = new File(I18nUtils.getLocalRepositoryFolder(I18nConfig.download.localRepoPath), "I18nRepo").getPath();
        } catch (IllegalArgumentException e) {
            shouldDisplayErrorScreen = true;
            return;
        }
        ResourcePackRepository repo = new ResourcePackRepository(localPath, builder.getAssetDomains());
        RepoUpdateManager updateManager = new RepoUpdateManager(repo);
        updateManager.update();
        if (updateManager.getStatus() == DownloadStatus.SUCCESS) {
            builder.updateAllNeededFilesFromRepo(repo);
            builder.touch();
            ShowNoticeFirst.shouldShowNotice = true;
        }
    }
}
 
Example 8
Source Project: GT-Classic   Source File: GTMod.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
@Mod.EventHandler
public void init(FMLInitializationEvent e) {
	GTMaterialElement.init();
	GTRecipeIterators.init();
	GTTileCentrifuge.init();
	GTTileUUMAssembler.init();
	GTTileMagicEnergyConverter.init();
	GTRecipe.initShapeless();
	GTRecipe.initItems();
	GTRecipe.initBlocks();
	GTRecipe.initIC2();
	GTRecipe.initIC2Circuits();
	GTRecipe.initIC2Jetpacks();
	GTRecipe.initIC2Overrides();
	GTRecipe.initProcessing();
	GTBedrockOreHandler.bedrockOresInit();
	GameRegistry.registerWorldGenerator(new GTWorldGen(), 0);
	MinecraftForge.EVENT_BUS.register(new GTEventOnLivingFall());
	MinecraftForge.EVENT_BUS.register(new GTEventLootTableLoad());
	MinecraftForge.EVENT_BUS.register(new GTEventCheckSpawn());
	MinecraftForge.EVENT_BUS.register(new GTEventEntityViewRenderEvent());
	MinecraftForge.EVENT_BUS.register(new GTEventPopulateChunk());
	MinecraftForge.EVENT_BUS.register(new GTEventItemTooltip());
	if (!Loader.isModLoaded(GTValues.MOD_ID_FASTLEAF)) {
		MinecraftForge.EVENT_BUS.register(new GTEventNeighborNotifyEvent());
	}
	MinecraftForge.TERRAIN_GEN_BUS.register(new GTEventDecorateBiome());
	IC2.saveManager.registerGlobal("IDSU_Storage", GTIDSUStorageManager.class, false);
	proxy.init(e);
}
 
Example 9
Source Project: GT-Classic   Source File: GTMod.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
@Mod.EventHandler
public void postInit(FMLPostInitializationEvent e) {
	proxy.postInit(e);
	GTMaterialGen.postInitProperities();
	GTRecipeIterators.postInit();
	GTTileMatterFabricator.postInit();
	GTTileMultiFusionReactor.postInit();
	GTRecipeMods.postInit();
	GTTileDisassembler.init();
	if (GTConfig.modcompat.compatTwilightForest && Loader.isModLoaded(GTValues.MOD_ID_TFOREST)) {
		GTTwilightForestHandler.initStalactites();
	}
}
 
Example 10
Source Project: ForgeHax   Source File: ForgeHax.java    License: MIT License 5 votes vote down vote up
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event) {
  if (event.getSide() == Side.CLIENT) {
    // ---- initialize mods ----//
    getModManager().loadAll();
  }
}
 
Example 11
Source Project: ForgeHax   Source File: ForgeHax.java    License: MIT License 5 votes vote down vote up
@Mod.EventHandler
public void init(FMLInitializationEvent event) {
  if (event.getSide() == Side.CLIENT) {
    // add shutdown hook to serialize all binds
    Runtime.getRuntime()
        .addShutdownHook(new Thread(() -> getModManager().forEach(BaseMod::unload)));
    
    // registerAll mod events
    getModManager().forEach(BaseMod::load);
  }
}
 
Example 12
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event)
{
    //Items and blocks
    if(proxy != null)
        proxy.subscribeEvents(event.getSuggestedConfigurationFile());

}
 
Example 13
Source Project: Valkyrien-Skies   Source File: ValkyrienSkiesControl.java    License: Apache License 2.0 5 votes vote down vote up
@Mod.EventHandler
public void init(FMLInitializationEvent event) {
    registerTileEntities();
    registerNetworks();
    registerCapabilities();
    proxy.init(event);
}
 
Example 14
Source Project: Valkyrien-Skies   Source File: ValkyrienSkiesMod.java    License: Apache License 2.0 5 votes vote down vote up
@Mod.EventHandler
public void onFingerprintViolation(FMLFingerprintViolationEvent event) {
    if (MixinLoaderForge.isObfuscatedEnvironment) { //only print signature warning in obf
        FMLLog.bigWarning(
            "Valkyrien Skies JAR fingerprint corrupted, which means this copy of the mod "
                + "may have come from unofficial sources. Please check out our official website: "
                + "https://valkyrienskies.org");
    }
}
 
Example 15
Source Project: Logistics-Pipes-2   Source File: LogisticsPipes2.java    License: MIT License 5 votes vote down vote up
@Mod.EventHandler
public void init(FMLInitializationEvent event){
	proxy.init(event);
	LPWorldGen worldGen = new LPWorldGen();
	GameRegistry.registerWorldGenerator(worldGen, 0);
	MinecraftForge.EVENT_BUS.register(worldGen);
}
 
Example 16
Source Project: GokiStats   Source File: GokiStats.java    License: MIT License 5 votes vote down vote up
@Mod.EventHandler
public void construct(FMLConstructionEvent event) {
    try {
        for (Class<?> clz : loadClasses)
            Class.forName(clz.getName());
    } catch (ClassNotFoundException e) {
        log.warn("Cannot load classes, this may cause some issues", e);
    }
}
 
Example 17
Source Project: GokiStats   Source File: GokiStats.java    License: MIT License 5 votes vote down vote up
@Mod.EventHandler
public void serverStart(FMLServerStartingEvent event) {
    MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
    ICommandManager command = server.getCommandManager();
    ServerCommandManager serverCommand = (ServerCommandManager) command;
    serverCommand.registerCommand(new StatsCommand());
    // TODO notice it's a reversion
}
 
Example 18
@Mod.EventHandler
@Override
@SuppressWarnings("deprecation")
public void init(FMLInitializationEvent evt) {
	try {
		proxy.init(evt);
		nativeConverters.stream().forEachOrdered(forgeLoadable -> forgeLoadable.init(evt));
		net.minecraftforge.fml.common.ProgressManager.ProgressBar progressBar
			= net.minecraftforge.fml.common.ProgressManager.push("Initializing NOVA wrappers",
				(novaModWrappers.isEmpty() ? 1 : novaModWrappers.size()) + novaWrappers.size());
		FMLProgressBar fmlProgressBar = new FMLProgressBar(progressBar);
		novaModWrappers.stream().forEachOrdered(wrapper -> {
			fmlProgressBar.step(wrapper.getClass());
			wrapper.init(evt);
		});
		novaWrappers.stream().forEachOrdered(wrapper -> {
			fmlProgressBar.step(wrapper.getClass());
			wrapper.init(evt);
		});
		fmlProgressBar.finish();
		net.minecraftforge.fml.common.ProgressManager.pop(progressBar);
	} catch (Exception e) {
		Game.logger().error("Error during init", e);
		e.printStackTrace();
		throw new InitializationException(e);
	}
}
 
Example 19
@Mod.EventHandler
@Override
@SuppressWarnings("deprecation")
public void postInit(FMLPostInitializationEvent evt) {
	try {
		proxy.postInit(evt);
		nativeConverters.stream().forEachOrdered(forgeLoadable -> forgeLoadable.postInit(evt));
		Game.recipes().init();
		net.minecraftforge.fml.common.ProgressManager.ProgressBar progressBar
			= net.minecraftforge.fml.common.ProgressManager.push("Post-initializing NOVA wrappers",
				(novaModWrappers.isEmpty() ? 1 : novaModWrappers.size()) + novaWrappers.size());
		FMLProgressBar fmlProgressBar = new FMLProgressBar(progressBar);
		novaModWrappers.stream().forEachOrdered(wrapper -> {
			fmlProgressBar.step(wrapper.getClass());
			wrapper.postInit(evt);
		});
		novaWrappers.stream().forEachOrdered(wrapper -> {
			fmlProgressBar.step(wrapper.getClass());
			wrapper.postInit(evt);
		});
		fmlProgressBar.finish();
		net.minecraftforge.fml.common.ProgressManager.pop(progressBar);
	} catch (Exception e) {
		Game.logger().error("Error during postInit", e);
		e.printStackTrace();
		throw new InitializationException(e);
	}
}
 
Example 20
Source Project: FastAsyncWorldedit   Source File: ForgeMain.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event) {
    this.logger = event.getModLog();
    File directory = new File(event.getModConfigurationDirectory() + File.separator + "FastAsyncWorldEdit");
    MinecraftForge.EVENT_BUS.register(this);
    FMLCommonHandler.instance().bus().register(this);
    this.IMP = new FaweForge(this, event.getModLog(), event.getModMetadata(), directory);
    try {
        Class.forName("org.spongepowered.api.Sponge");
        Settings.IMP.QUEUE.PARALLEL_THREADS = 1;
    } catch (Throwable ignore) {}
}
 
Example 21
Source Project: FastAsyncWorldedit   Source File: ForgeMain.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event) {
    this.logger = event.getModLog();
    File directory = new File(event.getModConfigurationDirectory() + File.separator + "FastAsyncWorldEdit");
    MinecraftForge.EVENT_BUS.register(this);
    FMLCommonHandler.instance().bus().register(this);
    this.IMP = new FaweForge(this, event.getModLog(), event.getModMetadata(), directory);
    try {
        Class.forName("org.spongepowered.api.Sponge");
        Settings.IMP.QUEUE.PARALLEL_THREADS = 1;
    } catch (Throwable ignore) {}
}
 
Example 22
Source Project: FastAsyncWorldedit   Source File: ForgeMain.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event) {
    this.logger = event.getModLog();
    File directory = new File(event.getModConfigurationDirectory() + File.separator + "FastAsyncWorldEdit");
    MinecraftForge.EVENT_BUS.register(this);
    FMLCommonHandler.instance().bus().register(this);
    this.IMP = new FaweForge(this, event.getModLog(), event.getModMetadata(), directory);
    try {
        Class.forName("org.spongepowered.api.Sponge");
        Settings.IMP.QUEUE.PARALLEL_THREADS = 1;
    } catch (Throwable ignore) {}
}
 
Example 23
Source Project: FastAsyncWorldedit   Source File: ForgeMain.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event) {
    this.logger = event.getModLog();
    File directory = new File(event.getModConfigurationDirectory() + File.separator + "FastAsyncWorldEdit");
    MinecraftForge.EVENT_BUS.register(this);
    FMLCommonHandler.instance().bus().register(this);
    this.IMP = new FaweForge(this, event.getModLog(), event.getModMetadata(), directory);
    try {
        Class.forName("org.spongepowered.api.Sponge");
        Settings.IMP.QUEUE.PARALLEL_THREADS = 1;
    } catch (Throwable ignore) {}
}
 
Example 24
Source Project: FastAsyncWorldedit   Source File: ForgeMain.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event) {
    this.logger = event.getModLog();
    File directory = new File(event.getModConfigurationDirectory() + File.separator + "FastAsyncWorldEdit");
    MinecraftForge.EVENT_BUS.register(this);
    FMLCommonHandler.instance().bus().register(this);
    this.IMP = new FaweForge(this, event.getModLog(), event.getModMetadata(), directory);
    try {
        Class.forName("org.spongepowered.api.Sponge");
        Settings.IMP.QUEUE.PARALLEL_THREADS = 1;
    } catch (Throwable ignore) {}
}
 
Example 25
Source Project: SkyblockAddons   Source File: SkyblockAddons.java    License: MIT License 4 votes vote down vote up
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent e) {
    configValues = new ConfigValues(this, e.getSuggestedConfigurationFile());
    persistentValues = new PersistentValues(e.getModConfigurationDirectory());
}
 
Example 26
Source Project: SkyblockAddons   Source File: SkyblockAddons.java    License: MIT License 4 votes vote down vote up
@Mod.EventHandler
public void stop(FMLModDisabledEvent e) {
    discordRPCManager.stop();
}
 
Example 27
Source Project: seppuku   Source File: SeppukuMod.java    License: GNU General Public License v3.0 4 votes vote down vote up
/**
 * Our mods entry point
 * @param event
 */
@Mod.EventHandler
public void init(FMLInitializationEvent event) {
    //initialize the client
    Seppuku.INSTANCE.init();
}
 
Example 28
@Mod.EventHandler
public void serverAboutToStart(FMLServerAboutToStartEvent event) {
    proxy.serverAboutToStart(event);
}
 
Example 29
@Mod.EventHandler
public void serverStopping(FMLServerStoppingEvent event) {
    proxy.serverStopping(event);
}
 
Example 30
Source Project: EmergingTechnology   Source File: EmergingTechnology.java    License: MIT License 4 votes vote down vote up
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event) {
  logger = event.getModLog();
  proxy.preInit(event);
}