private static ModContainer getModContainer() { return FMLCommonHandler.instance().findContainerFor(instance); }
/** * Helper registration method for a mod * @param mod A modid or mod instance * @param updateXML String that can be converted as an url for an xml file, listing mod versions and download links by Minecraft releases * @param changelog String that can be converted as an url for a file containing text to describe any changes, can be null * @throws MalformedURLException If no known protocol is found, or <tt>updateXML</tt> is <tt>null</tt>. */ public static void registerMod(Object mod, String updateXML, String changelog) throws MalformedURLException { registerMod(FMLCommonHandler.instance().findContainerFor(mod), updateXML, changelog); }
/** * Basic version checker, support having different build number on each side * @param mods the data sent from FML handshake packet * @param remoteParty the side that sent this data * @return true if we allow this to run */ @NetworkCheckHandler public boolean checkRemote(Map<String,String> mods, Side remoteParty){ if(mods.containsKey(MODID)){ String remoteVersion = mods.get(MODID); if(remoteVersion!=null) { String internalVersion = FMLCommonHandler.instance().findContainerFor(this).getVersion(); if(remoteVersion.equals(internalVersion)) return true; else{ internalVersion = internalVersion.substring(0, internalVersion.lastIndexOf(".")); remoteVersion = remoteVersion.substring(0, remoteVersion.lastIndexOf(".")); return remoteVersion.equals(internalVersion); } } } return false; } }
public static Entity createEntityByID(int tanEntityId, World worldIn) { Entity entity = null; ModContainer mc = FMLCommonHandler.instance().findContainerFor(ToughAsNails.instance); EntityRegistration er = EntityRegistry.instance().lookupModSpawn(mc, tanEntityId); if (er != null) { Class<? extends Entity> clazz = er.getEntityClass(); try { if (clazz != null) { entity = (Entity)clazz.getConstructor(new Class[] {World.class}).newInstance(new Object[] {worldIn}); } } catch (Exception exception) { exception.printStackTrace(); } } if (entity == null) { ToughAsNails.logger.warn("Skipping TAN Entity with id " + tanEntityId); } return entity; }
public static Entity createEntityByID(int tanEntityId, World worldIn) { Entity entity = null; ModContainer mc = FMLCommonHandler.instance().findContainerFor(FamiliarFauna.instance); EntityRegistration er = EntityRegistry.instance().lookupModSpawn(mc, tanEntityId); if (er != null) { Class<? extends Entity> clazz = er.getEntityClass(); try { if (clazz != null) { entity = (Entity)clazz.getConstructor(new Class[] {World.class}).newInstance(new Object[] {worldIn}); } } catch (Exception exception) { exception.printStackTrace(); } } if (entity == null) { FamiliarFauna.logger.warn("Skipping FF Entity with id " + tanEntityId); } return entity; }
public static void parseFiles() { ModContainer mod = FMLCommonHandler.instance().findContainerFor(ThermalExpansion.MOD_ID); parseCustomConstants(); parseConstants(mod); parseCustomContent(); parseContent(mod); }
@Mod.EventHandler public void preInit(FMLPreInitializationEvent event) { logger = event.getModLog(); knightArmourMaterial = EnumHelper.addArmorMaterial("knights.armour", "battlegear2:knight", 25, new int[]{3, 5, 7, 3}, 15, SoundEvents.ITEM_ARMOR_EQUIP_IRON, 1.5F); ResourceLocation sound = new ResourceLocation(MODID, "shield"); shieldSound = GameRegistry.register(new SoundEvent(sound).setRegistryName(sound)); BattlegearConfig.getConfig(new Configuration(event.getSuggestedConfigurationFile())); if((event.getSourceFile().getName().endsWith(".jar") || debug) && event.getSide().isClient()){ try { Class.forName("mods.mud.ModUpdateDetector").getDeclaredMethod("registerMod", ModContainer.class, String.class, String.class).invoke(null, FMLCommonHandler.instance().findContainerFor(this), "https://raw.github.com/Mine-and-blade-admin/Battlegear2/master/battlegear_update.xml", "https://raw.github.com/Mine-and-blade-admin/Battlegear2/master/changelog.md" ); } catch (Throwable e) { e.printStackTrace(); } } proxy.registerHandlers(); QuiverArrowRegistry.addArrowToRegistry(Items.ARROW, EntityTippedArrow.class); QuiverArrowRegistry.addArrowToRegistry(Items.TIPPED_ARROW, EntityTippedArrow.class); QuiverArrowRegistry.addArrowToRegistry(Items.SPECTRAL_ARROW, EntitySpectralArrow.class); //Fetch early messages IMCEvent imc = new IMCEvent(); imc.applyModContainer(FMLCommonHandler.instance().findContainerFor(MODID)); onMessage(imc); }
public static void register() { if (disableAll || registered) { return; } ModContainer callingContainer = Loader.instance().activeModContainer(); ModContainer cofhContainer = FMLCommonHandler.instance().findContainerFor(CoFHCore.MOD_ID); Loader.instance().setActiveModContainer(cofhContainer); MinecraftForge.EVENT_BUS.register(INSTANCE); registered = true; Loader.instance().setActiveModContainer(callingContainer); }
public static void register() { if (disableAll || registered) { return; } ModContainer callingContainer = Loader.instance().activeModContainer(); ModContainer cofhContainer = FMLCommonHandler.instance().findContainerFor(CoFHCore.MOD_ID); Loader.instance().setActiveModContainer(cofhContainer); MinecraftForge.EVENT_BUS.register(INSTANCE); registered = true; Loader.instance().setActiveModContainer(callingContainer); }