Java Code Examples for cpw.mods.fml.common.Loader

The following examples show how to use cpw.mods.fml.common.Loader. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: ehacks-pro   Source File: Nan0EventRegistar.java    License: GNU General Public License v3.0 6 votes vote down vote up
public static void register(EventBus bus, Object target) {
    ConcurrentHashMap<Object, ArrayList<IEventListener>> listeners = ReflectionHelper.getPrivateValue(EventBus.class, bus, "listeners");
    Map<Object, ModContainer> listenerOwners = ReflectionHelper.getPrivateValue(EventBus.class, bus, "listenerOwners");
    if (listeners.containsKey(target)) {
        return;
    }
    ModContainer activeModContainer = Loader.instance().getMinecraftModContainer();
    listenerOwners.put(target, activeModContainer);
    ReflectionHelper.setPrivateValue(EventBus.class, bus, listenerOwners, "listenerOwners");
    Set<? extends Class<?>> supers = TypeToken.of(target.getClass()).getTypes().rawTypes();
    for (Method method : target.getClass().getMethods()) {
        for (Class<?> cls : supers) {
            try {
                Method real = cls.getDeclaredMethod(method.getName(), method.getParameterTypes());
                if (real.isAnnotationPresent(SubscribeEvent.class)) {
                    Class<?>[] parameterTypes = method.getParameterTypes();
                    Class<?> eventType = parameterTypes[0];
                    register(bus, eventType, target, method, activeModContainer);
                    break;
                }
            } catch (NoSuchMethodException ignored) {
            }
        }
    }
}
 
Example 2
Source Project: ehacks-pro   Source File: GuiModIdConfig.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void drawScreen(int p_73863_1_, int p_73863_2_, float p_73863_3_) {
    this.drawDefaultBackground();
    this.drawCenteredString(this.fontRendererObj, "ModID configuration", this.width / 2, 15, 16777215);
    this.modId.drawTextBox();
    this.modVersion.drawTextBox();
    boolean nameOk = true;
    for (ModContainer container : Loader.instance().getActiveModList()) {
        if ((container.getModId() == null ? this.modId.getText() == null : container.getModId().equals(this.modId.getText())) && container.getMod() != INSTANCE) {
            nameOk = false;
            break;
        }
    }
    this.saveButton.enabled = "".equals(this.modId.getText()) || nameOk;
    this.drawString(this.fontRendererObj, "Mod ID (empty - no mod)", this.width / 2 - 100, this.height / 6 + 66 - 13, 16777215);
    this.drawString(this.fontRendererObj, "Mod Version", this.width / 2 - 100, this.height / 6 + 66 + 36 - 13, 16777215);
    super.drawScreen(p_73863_1_, p_73863_2_, p_73863_3_);
}
 
Example 3
public void run()
{
	GameRegistry.registerItem(QuantumBread.Instance(), "itemQuantumToast");
	if (Loader.isModLoaded("EnderIO"))
        FrankenskullFix.fixEnderIO();
	MaterialLoader.run();
	FluidPipeLoader.run();
	WireLoader.run();
    CasingLoader.run();
	ItemLoader.run();
	MachineLoader.run();
	BatteryLoader.run();
	Remover.run();
    MachineRecipeLoader.run();
    CraftingRecipeLoader.run();
    OreDictionary.run();
}
 
Example 4
@Override
public List<String> getWailaTail(Entity paramEntity, List<String> strings, IWailaEntityAccessor data, IWailaConfigHandler config) {
    if(data.getEntity() instanceof EntityGolemBase) {
        AdditionalGolemType type = GadomancyApi.getAdditionalGolemType(((EntityGolemBase) data.getEntity()).getGolemType());
        if(type != null && strings.size() > 0) {
            String oldMod = strings.get(strings.size() - 1);

            ModContainer container = Loader.instance().getIndexedModList().get(type.getModId());
            if(container != null) {
                String mod = ColorHelper.extractColors(oldMod) + container.getName();

                strings.remove(strings.size() - 1);
                strings.add(mod);
            }
        }
    }
    return strings;
}
 
Example 5
private static void registerDependent(String modId, String clazz) {
    if(!Loader.isModLoaded(modId)) {
        return;
    }

    Object integration;
    try {
        integration = Injector.getClass(clazz).newInstance();
    } catch (Throwable e) {//InstantiationException | IllegalAccessException
        return;
    }

    if(integration instanceof IntegrationMod) {
        ((IntegrationMod) integration).init();
    }
}
 
Example 6
Source Project: Et-Futurum   Source File: EtFuturum.java    License: The Unlicense 6 votes vote down vote up
@EventHandler
public void init(FMLInitializationEvent event) {
	NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy);

	ModRecipes.init();

	proxy.registerEvents();
	proxy.registerEntities();
	proxy.registerRenderers();

	if (ModEntityList.hasEntitiesWithEggs()) {
		ModEntityList.entity_egg = new ItemEntityEgg();
		GameRegistry.registerItem(ModEntityList.entity_egg, "entity_egg");
		OreDictionary.registerOre("mobEgg", ModEntityList.entity_egg);
	}

	isTinkersConstructLoaded = Loader.isModLoaded("TConstruct");
}
 
Example 7
Source Project: Ex-Aliquo   Source File: Crossmod.java    License: MIT License 6 votes vote down vote up
public static void initCross()
{
	if (isArsMagicaLoaded && isTConLoaded)
	{
		ArsMagica_Tinker.SmeltArs();
	}
	if (isThaumcraftLoaded && isNetherOresLoaded)
	{
		NetherOres_Thaumcraft.Whenk();
	}
	if (isExtraTICLoaded && isMetallurgyLoaded)
	{
		ExtraTic_Metallurgy.SmeltMetallurgy();
	}
	if (isExtraTICLoaded && Loader.isModLoaded("Mekanisum"))
	{
		ExtraTic_Mekanism.SmeltMekanism();
	}
	CropXYZ.Shoukan();
}
 
Example 8
Source Project: GardenCollection   Source File: WitcheryIntegration.java    License: MIT License 6 votes vote down vote up
public static void init () {
    if (!Loader.isModLoaded(MOD_ID))
        return;

    initWood();

    GardenCoreAPI.instance().registerBonemealHandler(new BonemealHandler());

    PlantRegistry plantReg = PlantRegistry.instance();

    plantReg.registerPlantInfo(MOD_ID, "embermoss", new SimplePlantInfo(PlantType.GROUND, PlantSize.LARGE));
    plantReg.registerPlantInfo(MOD_ID, "leapinglily", new SimplePlantInfo(PlantType.AQUATIC_COVER, PlantSize.LARGE));
    plantReg.registerPlantInfo(MOD_ID, "spanishmoss", new SimplePlantInfo(PlantType.HANGING_SIDE, PlantSize.LARGE));
    plantReg.registerPlantInfo(MOD_ID, "bramble", new SimplePlantInfo(PlantType.GROUND, PlantSize.FULL));
    plantReg.registerPlantInfo(MOD_ID, "glintweed", new SimplePlantInfo(PlantType.GROUND, PlantSize.LARGE));
    plantReg.registerPlantInfo(MOD_ID, "voidbramble", new SimplePlantInfo(PlantType.GROUND, PlantSize.FULL));

    plantReg.registerPlantInfo(MOD_ID, "seedsartichoke", 0, new SimplePlantInfo(PlantType.AQUATIC_SURFACE, PlantSize.LARGE));
    plantReg.registerPlantInfo(MOD_ID, "seedswormwood", 0, new SimplePlantInfo(PlantType.GROUND, PlantSize.LARGE));
    plantReg.registerPlantInfo(MOD_ID, "seedsmandrake", 0, new SimplePlantInfo(PlantType.GROUND, PlantSize.FULL));
    plantReg.registerPlantInfo(MOD_ID, "seedswolfsbane", 0, new SimplePlantInfo(PlantType.GROUND, PlantSize.LARGE));
    plantReg.registerPlantInfo(MOD_ID, "seedsbelladonna", 0, new SimplePlantInfo(PlantType.GROUND, PlantSize.FULL));
    plantReg.registerPlantInfo(MOD_ID, "seedssnowbell", 0, new SimplePlantInfo(PlantType.GROUND, PlantSize.LARGE));
    plantReg.registerPlantInfo(MOD_ID, "garlic", 0, new SimplePlantInfo(PlantType.GROUND, PlantSize.FULL));
}
 
Example 9
Source Project: GardenCollection   Source File: WeeeFlowersIntegration.java    License: MIT License 6 votes vote down vote up
public static void init () {
    if (!Loader.isModLoaded(MOD_ID))
        return;

    String[] pamColors = new String[] { "White", "Orange", "Magenta", "Light Blue", "Yellow", "Lime", "Pink",
        "Light Grey", "Dark Grey", "Cyan", "Purple", "Blue", "Brown", "Green", "Red", "Black" };

    PlantRegistry plantReg = PlantRegistry.instance();

    for (int i : new int[] { 3, 4, 5, 6, 8, 9, 10, 11, 12 })
        plantReg.registerPlantInfo(MOD_ID, "Flower", i, new SimplePlantInfo(PlantType.GROUND, PlantSize.LARGE));

    for (String color : pamColors) {
        plantReg.registerPlantInfo(MOD_ID, color + " Flower Crop", new SimplePlantInfo(PlantType.GROUND, PlantSize.FULL));
        plantReg.registerPlantInfo(MOD_ID, color + " Vine", new SimplePlantInfo(PlantType.HANGING_SIDE, PlantSize.LARGE));
    }
}
 
Example 10
Source Project: GardenCollection   Source File: ModIntegration.java    License: MIT License 6 votes vote down vote up
public void postInit () {
    IntegrationRegistry.instance().postInit();

    //BiomesOPlenty.init();
    ExtraBiomesXLIntegration.init();
    NaturaIntegration.init();
    TwilightForestIntegration.init();
    WeeeFlowersIntegration.init();
    //Botania.init();
    ThaumcraftIntegration.init();
    //AgriCraft.init();
    MineTweakerIntegration.init();
    WitcheryIntegration.init();

    if (Loader.isModLoaded("plantmegapack"))
        PlantMegaPackIntegration.init();
}
 
Example 11
Source Project: GardenCollection   Source File: IntegrationRegistry.java    License: MIT License 6 votes vote down vote up
public void init () {
    for (int i = 0; i < registry.size(); i++) {
        IntegrationModule module = registry.get(i);
        if (module.getModID() != null && !Loader.isModLoaded(module.getModID())) {
            registry.remove(i--);
            continue;
        }

        try {
            module.init();
        }
        catch (Throwable t) {
            registry.remove(i--);
            FMLLog.log(GardenStuff.MOD_ID, Level.INFO, "Could not load integration module: " + module.getClass().getName() + " (init)");
        }
    }
}
 
Example 12
Source Project: GardenCollection   Source File: TwilightForestIntegration.java    License: MIT License 6 votes vote down vote up
public static void init () {
    if (!Loader.isModLoaded(MOD_ID))
        return;

    try {
        classEntityFirefly = Class.forName("twilightforest.entity.passive.EntityTFTinyFirefly");
        classRenderFirefly = Class.forName("twilightforest.client.renderer.entity.RenderTFTinyFirefly");

        constEntityFirefly = classEntityFirefly.getConstructor(World.class, double.class, double.class, double.class);
        constRenderFirefly = classRenderFirefly.getConstructor();

        if (GardenStuff.proxy instanceof ClientProxy)
            registerEntity();

        Block blockFirefly = GameRegistry.findBlock(MOD_ID, "tile.TFFirefly");
        ILanternSource fireflySource = new FireflyLanternSource(blockFirefly);

        GardenAPI.instance().registries().lanternSources().registerLanternSource(fireflySource);

        initialized = true;
    }
    catch (Throwable t) { }
}
 
Example 13
Source Project: PneumaticCraft   Source File: GuiProgrammer.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void drawGuiContainerForegroundLayer(int x, int y){
    super.drawGuiContainerForegroundLayer(x, y);

    boolean igwLoaded = Loader.isModLoaded(ModIds.IGWMOD);
    fontRendererObj.drawString(widgetPage + 1 + "/" + (maxPage + 1), 305, 175, 0xFF000000);
    fontRendererObj.drawString(I18n.format("gui.programmer.difficulty"), 263, 190, 0xFF000000);

    if(showingWidgetProgress == 0) {
        programmerUnit.renderForeground(x, y, draggingWidget);
    }

    for(IProgWidget widget : visibleSpawnWidgets) {
        if(widget != draggingWidget && x - guiLeft >= widget.getX() && y - guiTop >= widget.getY() && x - guiLeft <= widget.getX() + widget.getWidth() / 2 && y - guiTop <= widget.getY() + widget.getHeight() / 2) {
            List<String> tooltip = new ArrayList<String>();
            widget.getTooltip(tooltip);
            if(igwLoaded) tooltip.add(I18n.format("gui.programmer.pressIForInfo"));
            if(tooltip.size() > 0) drawHoveringString(tooltip, x - guiLeft, y - guiTop, fontRendererObj);
        }
    }

}
 
Example 14
@Override
public void initGui(){
    super.initGui();
    addAnimatedStat("gui.tab.info.ghostSlotInteraction.title", new ItemStack(Blocks.hopper), 0xFF00AAFF, true).setText("gui.tab.info.ghostSlotInteraction");
    if(Loader.isModLoaded(ModIds.AE2)) {
        if(logistics.isPlacedOnInterface()) {
            Item item = GameRegistry.findItem(ModIds.AE2, "item.ItemMultiPart");
            if(item == null) {
                Log.warning("AE2 cable couldn't be found!");
                item = Itemss.logisticsFrameRequester;
            }
            GuiAnimatedStat stat = addAnimatedStat("gui.tab.info.logisticsRequester.aeIntegration.title", new ItemStack(item, 1, 16), 0xFF00AAFF, false);
            List<String> text = new ArrayList<String>();
            for(int i = 0; i < 2; i++)
                text.add("");
            text.add("gui.tab.info.logisticsRequester.aeIntegration");
            stat.setText(text);
            stat.addWidget(aeIntegration = new GuiCheckBox(1, 16, 13, 0xFF000000, "gui.tab.info.logisticsRequester.aeIntegration.enable"));
        }
    }
}
 
Example 15
Source Project: PneumaticCraft   Source File: Waila.java    License: GNU General Public License v3.0 6 votes vote down vote up
public static void callbackRegister(IWailaRegistrar registrar){
    registrar.registerBodyProvider(new WailaPneumaticHandler(), IPneumaticMachine.class);
    registrar.registerBodyProvider(new WailaHeatHandler(), IHeatExchanger.class);
    registrar.registerBodyProvider(new WailaPlantHandler(), BlockPneumaticPlantBase.class);
    registrar.registerBodyProvider(new WailaSemiBlockHandler(), Block.class);
    registrar.registerBodyProvider(new WailaRedstoneControl(), IRedstoneControl.class);
    registrar.registerBodyProvider(new WailaTubeModuleHandler(), TileEntityPressureTube.class);
    registrar.registerNBTProvider(new WailaPneumaticHandler(), IPneumaticMachine.class);
    registrar.registerNBTProvider(new WailaHeatHandler(), IHeatExchanger.class);
    registrar.registerNBTProvider(new WailaTubeModuleHandler(), TileEntityPressureTube.class);
    registrar.registerNBTProvider(new WailaSemiBlockHandler(), Block.class);
    registrar.registerNBTProvider(new WailaRedstoneControl(), IRedstoneControl.class);

    if(Loader.isModLoaded(ModIds.FMP)) {
        registrar.registerBodyProvider(new WailaFMPHandler(), "tile.pressureTube");
        registrar.registerBodyProvider(new WailaFMPHandler(), "tile.advancedPressureTube");
    }
}
 
Example 16
Source Project: bartworks   Source File: LoaderReference.java    License: MIT License 5 votes vote down vote up
public static void init() {
    Natura = Loader.isModLoaded("Natura");
    RandomThings = Loader.isModLoaded("RandomThings");
    TConstruct = Loader.isModLoaded("TConstruct");
    chisel = Loader.isModLoaded("chisel");
    Railcraft = Loader.isModLoaded("Railcraft");
    Ztones = Loader.isModLoaded("Ztones");
    witchery = Loader.isModLoaded("witchery");
    GalaxySpace = Loader.isModLoaded("GalaxySpace");
    GalacticraftCore = Loader.isModLoaded("GalacticraftCore");
    GalacticraftMars = Loader.isModLoaded("GalacticraftMars");
    Thaumcraft = Loader.isModLoaded("Thaumcraft");
    miscutils = Loader.isModLoaded("miscutils");
    tectech = Loader.isModLoaded("tectech");
    ExtraUtilities = Loader.isModLoaded("ExtraUtilities");
    RWG = Loader.isModLoaded("RWG");
    galacticgreg = Loader.isModLoaded("galacticgreg");
    gendustry = Loader.isModLoaded("gendustry");
    croploadcore = Loader.isModLoaded("croploadcore");
    Forestry = Loader.isModLoaded("Forestry");
    berriespp = Loader.isModLoaded("berriespp");
    dreamcraft = Loader.isModLoaded("dreamcraft");
    BloodArsenal = Loader.isModLoaded("BloodArsenal");
    Botany = Loader.isModLoaded("Botany");
    EnderIO = Loader.isModLoaded("EnderIO");
    HardcoreEnderExpension = Loader.isModLoaded("HardcoreEnderExpension");
    betterloadingscreen = Loader.isModLoaded("betterloadingscreen");
}
 
Example 17
public static void reg_additional() {
	if(Loader.isModLoaded("GalaxySpace"))
	for (byte i = 0; i<6; i++) {
		OreDictionary.registerOre("cropSpace", GT_ModHandler.getModItem("GalaxySpace", "tcetiedandelions", 1L,i));
		OreDictionary.registerOre("cropTcetiESeaweed", GT_ModHandler.getModItem("GalaxySpace", "tcetiedandelions", 1L,i));
	}

	OreDictionary.registerOre("foodSalt", ItemList.EdibleSalt.getIS());

	//Olivine = Peridot
	for (int i = 0; i < OreDictionary.getOres("blockOlivine").size(); i++) {
		OreDictionary.registerOre("blockPeridot", OreDictionary.getOres("blockOlivine").get(i));
	}
}
 
Example 18
@Mod.EventHandler
public void load(FMLInitializationEvent event)
{
    // register events in modules
    RegisterModuleEvents();

    if (CoreConfig.ModBabyChest_Enabled) {
        InitAdditionalBlocks();
    }
    
    // Register additional OreDictionary Names
    if(CoreConfig.OreDictItems_Enabled)
    OreDictHandler.register_all();

    // Register Dimensions in GalacticGregGT5
    if (Loader.isModLoaded("galacticgreg"))
    {
        if (Loader.isModLoaded("bartworks")) {
            GregTech_API.sAfterGTPostload.add(() -> {
                Logger.debug("Add Runnable to GT to add Ores to BW VoidMiner in the DeepDark");
                VoidMinerLoader.initDeepDark();
            });
        }

        SpaceDimReg = new SpaceDimRegisterer();
        if (!SpaceDimReg.Init())
        {
            Logger.error("Unable to register SpaceDimensions; You are probably using the wrong Version of GalacticGreg");
            AddLoginError("[SpaceDim] Unable to register SpaceDimensions. Wrong Version of GGreg found!");
        }
        else
        {
            Logger.debug("Registering SpaceDimensions");
            SpaceDimReg.Register();
        }

    }
}
 
Example 19
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item par1, CreativeTabs tab, List subItems){
    for(int i = 0; i < UPGRADES_AMOUNT; i++) {
        if(i != UPGRADE_THAUMCRAFT || Loader.isModLoaded(ModIds.THAUMCRAFT)) subItems.add(new ItemStack(this, 1, i));
    }
}
 
Example 20
private static <T extends Item> T registerItem(String modId, T item, String name) {
    Injector modController = new Injector(new Injector(Loader.instance(), Loader.class).getField("modController"), LoadController.class);
    Object old = modController.getField("activeContainer");
    modController.setField("activeContainer", Loader.instance().getIndexedModList().get(modId));

    GameRegistry.registerItem(item, name);

    modController.setField("activeContainer", old);
    return item;
}
 
Example 21
Source Project: ChickenChunks   Source File: ChunkLoaderManager.java    License: MIT License 5 votes vote down vote up
/**
 * By doing this you are delegating all chunks from your mod to be handled by yours truly.
 */
public static void registerMod(Object mod) {
    ModContainer container = Loader.instance().getModObjectList().inverse().get(mod);
    if (container == null)
        throw new NullPointerException("Mod container not found for: " + mod);
    mods.put(mod, container);
    ForgeChunkManager.setForcedChunkLoadingCallback(mod, new DummyLoadingCallback());
}
 
Example 22
private static boolean sameOrNewerVersion(String modid, String version) {
	final ModContainer modContainer = Loader.instance().getIndexedModList().get(modid);
	if (modContainer == null) return true;

	final ArtifactVersion targetVersion = new DefaultArtifactVersion(version);
	final ArtifactVersion actualVersion = modContainer.getProcessedVersion();
	return actualVersion.compareTo(targetVersion) >= 0;
}
 
Example 23
Source Project: NEI-Integration   Source File: LoadedModDumper.java    License: MIT License 5 votes vote down vote up
@Override
public Iterable<String[]> dump(int mode) {
    List<String[]> list = new LinkedList<String[]>();
    
    for (ModContainer mod : Loader.instance().getModList()) {
        list.add(new String[] { mod.getModId(), mod.getName(), mod.getVersion(), String.valueOf(!(mod instanceof FMLModContainer)), String.valueOf(mod.canBeDisabled()), mod.getDependencies().toString() });
    }
    
    return list;
}
 
Example 24
Source Project: NEI-Integration   Source File: Utils.java    License: MIT License 5 votes vote down vote up
public static boolean isModLoaded(String modid, String versionRangeString) {
    if (!isModLoaded(modid)) {
        return false;
    }
    
    ModContainer mod = Loader.instance().getIndexedModList().get(modid);
    VersionRange versionRange = VersionParser.parseRange(versionRangeString);
    DefaultArtifactVersion required = new DefaultArtifactVersion(modid, versionRange);
    
    return required.containsVersion(mod.getProcessedVersion());
}
 
Example 25
Source Project: NEI-Integration   Source File: FuelManager.java    License: MIT License 5 votes vote down vote up
/**
 * Register the amount of heat in a bucket of liquid fuel.
 *
 * @param fluid
 * @param heatValuePerBucket
 */
public static void addBoilerFuel(Fluid fluid, int heatValuePerBucket) {
    ModContainer mod = Loader.instance().activeModContainer();
    String modName = mod != null ? mod.getName() : "An Unknown Mod";
    if (fluid == null) {
        FMLLog.log("Railcraft", Level.WARN, String.format("An error occured while %s was registering a Boiler fuel source", modName));
        return;
    }
    boilerFuel.put(fluid, heatValuePerBucket);
    FMLLog.log("Railcraft", Level.DEBUG, String.format("%s registered \"%s\" as a valid Boiler fuel source with %d heat.", modName, fluid.getName(), heatValuePerBucket));
}
 
Example 26
Source Project: Ex-Aliquo   Source File: Metallurgy.java    License: MIT License 5 votes vote down vote up
public static void initMetallurgy()
{
	//Hammering.HammerMetallurgy();
	//OreDict.registerExMetallurgyOreDict();
	if (Loader.isModLoaded("ExtraTiC")) 
	{
		System.out.println("Smelting Metallurgy metals");
		Smelting.SmeltMetallurgy();
	}
}
 
Example 27
Source Project: Artifacts   Source File: DragonArtifacts.java    License: MIT License 5 votes vote down vote up
@EventHandler
public void PostInit(FMLPostInitializationEvent event) 
{
	baublesLoaded = Loader.isModLoaded("Baubles");
	mystcraftLoaded = Loader.isModLoaded("Mystcraft");
	//System.out.println("[Artifacts] Is Baubles Loaded? " + baublesLoaded);
	//System.out.println("[Artifacts] Is Mystcraft Loaded? " + mystcraftLoaded);
}
 
Example 28
Source Project: MyTown2   Source File: Protection.java    License: The Unlicense 5 votes vote down vote up
private static boolean isModLoaded(String modid, String name, String version) {
	if ("Minecraft".equals(modid)) {
		return true;
	}
    for(ModContainer mod : Loader.instance().getModList()) {
        if(mod.getModId().equals(modid) && (name.length() == 0 || mod.getName().equals(name)) && mod.getVersion().startsWith(version)) {
            return true;
        }
    }
    return false;
}
 
Example 29
Source Project: GardenCollection   Source File: TwilightForestIntegration.java    License: MIT License 5 votes vote down vote up
public static void init () {
    if (!Loader.isModLoaded(MOD_ID))
        return;

    Map<String, int[]> saplingBank1 = new HashMap<String, int[]>();
    saplingBank1.put("small_oak", new int[] { 0, 7, 8, 9 });
    saplingBank1.put("large_oak", new int[] { 4, 5 });
    saplingBank1.put("small_canopy", new int[] { 1, 2, 3, 6 });

    Map<Item, Map<String, int[]>> banks = new HashMap<Item, Map<String, int[]>>();
    banks.put(Item.getItemFromBlock(GameRegistry.findBlock(MOD_ID, "tile.TFSapling")), saplingBank1);

    SaplingRegistry saplingReg = SaplingRegistry.instance();

    for (Map.Entry<Item, Map<String, int[]>> entry : banks.entrySet()) {
        Item sapling = entry.getKey();

        for (Map.Entry<String, int[]> bankEntry : entry.getValue().entrySet()) {
            OrnamentalTreeFactory factory = OrnamentalTreeRegistry.getTree(bankEntry.getKey());
            if (factory == null)
                continue;

            for (int i : bankEntry.getValue()) {
                UniqueMetaIdentifier woodBlock = saplingReg.getWoodForSapling(sapling, i);
                UniqueMetaIdentifier leafBlock = saplingReg.getLeavesForSapling(sapling, i);
                if (woodBlock == null || leafBlock == null)
                    continue;

                saplingReg.putExtendedData(sapling, i, "sm_generator",
                    factory.create(woodBlock.getBlock(), woodBlock.meta, leafBlock.getBlock(), leafBlock.meta));
            }
        }
    }
}
 
Example 30
Source Project: OpenPeripheral-Addons   Source File: Recipes.java    License: MIT License 5 votes vote down vote up
public static void register() {
	final ItemStack duckAntenna = MetasGeneric.duckAntenna.newItemStack();

	@SuppressWarnings("unchecked")
	final List<IRecipe> recipeList = CraftingManager.getInstance().getRecipeList();

	if (OpenPeripheralAddons.Blocks.pim != null) {
		recipeList.add(new ShapedOreRecipe(OpenPeripheralAddons.Blocks.pim, "ooo", "rcr", 'o', Blocks.obsidian, 'r', Items.redstone, 'c', Blocks.chest));
	}

	if (OpenPeripheralAddons.Blocks.sensor != null) {
		recipeList.add(new ShapedOreRecipe(OpenPeripheralAddons.Blocks.sensor, "ooo", " w ", "sss", 'o', Blocks.obsidian, 'w', "stickWood", 's', Blocks.stone_slab));
	}

	if (OpenPeripheralAddons.Blocks.glassesBridge != null) {
		recipeList.add(new ShapedOreRecipe(OpenPeripheralAddons.Blocks.glassesBridge, "sas", "ses", "srs", 's', Blocks.stone, 'r', Blocks.redstone_block, 'e', Items.ender_pearl, 'a', duckAntenna.copy()));
	}

	if (OpenPeripheralAddons.Blocks.selector != null) {
		recipeList.add(new ShapedOreRecipe(OpenPeripheralAddons.Blocks.selector, "sss", "scs", "sgs", 's', Blocks.stone, 'c', Blocks.trapped_chest, 'g', Blocks.glass_pane));
	}

	if (OpenPeripheralAddons.Items.glasses != null) {
		recipeList.add(new ShapedOreRecipe(OpenPeripheralAddons.Items.glasses, "igi", "aei", "prp", 'g', Blocks.glowstone, 'i', Items.iron_ingot, 'e', Items.ender_pearl, 'p', Blocks.glass_pane, 'r', Items.redstone, 'a', duckAntenna.copy()));
		recipeList.add(new ShapedOreRecipe(OpenPeripheralAddons.Items.glasses, "igi", "iea", "prp", 'g', Blocks.glowstone, 'i', Items.iron_ingot, 'e', Items.ender_pearl, 'p', Blocks.glass_pane, 'r', Items.redstone, 'a', duckAntenna.copy()));

		recipeList.add(new TerminalAddonRecipe());
		RecipeSorter.register("openperipheraladdons:terminal", TerminalAddonRecipe.class, RecipeSorter.Category.SHAPELESS, "after:minecraft:shapeless");
	}

	if (OpenPeripheralAddons.Items.keyboard != null) {
		recipeList.add(new ShapelessOreRecipe(OpenPeripheralAddons.Items.keyboard, duckAntenna.copy(), Items.bone, Items.redstone, Items.ender_pearl, Items.slime_ball));
	}

	if (Loader.isModLoaded(Mods.COMPUTERCRAFT)) ModuleComputerCraft.registerRecipes(recipeList);
	if (Loader.isModLoaded(Mods.RAILCRAFT)) ModuleRailcraft.registerRecipes(recipeList);

}