Search in sources :

Example 76 with Material

use of gregtech.api.unification.material.Material in project GregTech by GregTechCEu.

the class GTJeiPlugin method register.

@Override
public void register(IModRegistry registry) {
    IJeiHelpers jeiHelpers = registry.getJeiHelpers();
    registry.addRecipes(IntCircuitRecipeWrapper.create(), IntCircuitCategory.UID);
    MultiblockInfoCategory.registerRecipes(registry);
    registry.handleRecipes(CustomItemReturnShapedOreRecipeRecipe.class, recipe -> new CustomItemReturnRecipeWrapper(jeiHelpers, recipe), VanillaRecipeCategoryUid.CRAFTING);
    registry.addRecipeRegistryPlugin(new FacadeRegistryPlugin());
    // register transfer handler for all categories, but not for the crafting station
    ModularUIGuiHandler modularUIGuiHandler = new ModularUIGuiHandler(jeiHelpers.recipeTransferHandlerHelper());
    modularUIGuiHandler.setValidHandlers(widget -> !(widget instanceof CraftingSlotWidget));
    registry.getRecipeTransferRegistry().addRecipeTransferHandler(modularUIGuiHandler, Constants.UNIVERSAL_RECIPE_TRANSFER_UID);
    registry.addAdvancedGuiHandlers(modularUIGuiHandler);
    registry.addGhostIngredientHandler(modularUIGuiHandler.getGuiContainerClass(), modularUIGuiHandler);
    // register transfer handler for crafting recipes
    ModularUIGuiHandler craftingStationGuiHandler = new ModularUIGuiHandler(jeiHelpers.recipeTransferHandlerHelper());
    registry.getRecipeTransferRegistry().addRecipeTransferHandler(craftingStationGuiHandler, VanillaRecipeCategoryUid.CRAFTING);
    for (RecipeMap<?> recipeMap : RecipeMap.getRecipeMaps()) {
        if (!recipeMap.isHidden) {
            Stream<Recipe> recipeStream = recipeMap.getRecipeList().stream().filter(recipe -> !recipe.isHidden() && recipe.hasValidInputsForDisplay());
            if (recipeMap.getSmallRecipeMap() != null) {
                Collection<Recipe> smallRecipes = recipeMap.getSmallRecipeMap().getRecipeList();
                recipeStream = recipeStream.filter(recipe -> !smallRecipes.contains(recipe));
            }
            registry.addRecipes(recipeStream.map(r -> new GTRecipeWrapper(recipeMap, r)).collect(Collectors.toList()), GTValues.MODID + ":" + recipeMap.unlocalizedName);
        }
    }
    for (ResourceLocation metaTileEntityId : GregTechAPI.MTE_REGISTRY.getKeys()) {
        MetaTileEntity metaTileEntity = GregTechAPI.MTE_REGISTRY.getObject(metaTileEntityId);
        assert metaTileEntity != null;
        if (metaTileEntity.getCapability(GregtechTileCapabilities.CAPABILITY_CONTROLLABLE, null) != null) {
            IControllable workableCapability = metaTileEntity.getCapability(GregtechTileCapabilities.CAPABILITY_CONTROLLABLE, null);
            if (workableCapability instanceof AbstractRecipeLogic) {
                AbstractRecipeLogic logic = (AbstractRecipeLogic) workableCapability;
                if (metaTileEntity instanceof IMultipleRecipeMaps) {
                    for (RecipeMap<?> recipeMap : ((IMultipleRecipeMaps) metaTileEntity).getAvailableRecipeMaps()) {
                        registerRecipeMapCatalyst(registry, recipeMap, metaTileEntity);
                    }
                } else if (logic.getRecipeMap() != null) {
                    registerRecipeMapCatalyst(registry, logic.getRecipeMap(), metaTileEntity);
                }
            }
        }
    }
    String semiFluidMapId = GTValues.MODID + ":" + RecipeMaps.SEMI_FLUID_GENERATOR_FUELS.getUnlocalizedName();
    registry.addRecipeCatalyst(MetaTileEntities.LARGE_BRONZE_BOILER.getStackForm(), semiFluidMapId);
    registry.addRecipeCatalyst(MetaTileEntities.LARGE_STEEL_BOILER.getStackForm(), semiFluidMapId);
    registry.addRecipeCatalyst(MetaTileEntities.LARGE_TITANIUM_BOILER.getStackForm(), semiFluidMapId);
    registry.addRecipeCatalyst(MetaTileEntities.LARGE_TUNGSTENSTEEL_BOILER.getStackForm(), semiFluidMapId);
    List<OreByProduct> oreByproductList = new CopyOnWriteArrayList<>();
    for (Material material : GregTechAPI.MATERIAL_REGISTRY) {
        if (material.hasProperty(PropertyKey.ORE)) {
            oreByproductList.add(new OreByProduct(material));
        }
    }
    String oreByProductId = GTValues.MODID + ":" + "ore_by_product";
    registry.addRecipes(oreByproductList, oreByProductId);
    MetaTileEntity[][] machineLists = new MetaTileEntity[][] { MetaTileEntities.MACERATOR, MetaTileEntities.ORE_WASHER, MetaTileEntities.CENTRIFUGE, MetaTileEntities.THERMAL_CENTRIFUGE, MetaTileEntities.CHEMICAL_BATH, MetaTileEntities.ELECTROMAGNETIC_SEPARATOR, MetaTileEntities.SIFTER };
    for (MetaTileEntity[] machine : machineLists) {
        if (machine.length < GTValues.LV + 1 || machine[GTValues.LV] == null)
            continue;
        registry.addRecipeCatalyst(machine[GTValues.LV].getStackForm(), oreByProductId);
    }
    // Material Tree
    List<MaterialTree> materialTreeList = new CopyOnWriteArrayList<>();
    for (Material material : GregTechAPI.MATERIAL_REGISTRY) {
        if (material.hasProperty(PropertyKey.DUST)) {
            materialTreeList.add(new MaterialTree(material));
        }
    }
    registry.addRecipes(materialTreeList, GTValues.MODID + ":" + "material_tree");
    // Ore Veins
    List<OreDepositDefinition> oreVeins = WorldGenRegistry.getOreDeposits();
    List<GTOreInfo> oreInfoList = new CopyOnWriteArrayList<>();
    for (OreDepositDefinition vein : oreVeins) {
        oreInfoList.add(new GTOreInfo(vein));
    }
    String oreSpawnID = GTValues.MODID + ":" + "ore_spawn_location";
    registry.addRecipes(oreInfoList, oreSpawnID);
    registry.addRecipeCatalyst(MetaItems.PROSPECTOR_LV.getStackForm(), oreSpawnID);
    registry.addRecipeCatalyst(MetaItems.PROSPECTOR_HV.getStackForm(), oreSpawnID);
    registry.addRecipeCatalyst(MetaItems.PROSPECTOR_LUV.getStackForm(), oreSpawnID);
    // Ore Veins End
    ingredientRegistry = registry.getIngredientRegistry();
    for (int i = 0; i <= IntCircuitIngredient.CIRCUIT_MAX; i++) {
        registry.addIngredientInfo(IntCircuitIngredient.getIntegratedCircuit(i), VanillaTypes.ITEM, "metaitem.circuit.integrated.jei_description");
    }
    registry.addRecipeCatalyst(MetaTileEntities.WORKBENCH.getStackForm(), VanillaRecipeCategoryUid.CRAFTING);
    for (MetaTileEntity machine : MetaTileEntities.CANNER) {
        if (machine == null)
            continue;
        registry.addIngredientInfo(machine.getStackForm(), VanillaTypes.ITEM, "gregtech.machine.canner.jei_description");
    }
    // Multiblock info page registration
    MultiblockInfoCategory.REGISTER.forEach(mte -> {
        String[] desc = mte.getDescription();
        if (desc.length > 0) {
            registry.addIngredientInfo(mte.getStackForm(), VanillaTypes.ITEM, mte.getDescription());
        }
    });
}
Also used : OreByProductCategory(gregtech.integration.jei.recipe.primitive.OreByProductCategory) gregtech.integration.jei.utils(gregtech.integration.jei.utils) Item(net.minecraft.item.Item) MetaTileEntities(gregtech.common.metatileentities.MetaTileEntities) IRecipeCategoryRegistration(mezz.jei.api.recipe.IRecipeCategoryRegistration) ObfuscationReflectionHelper(net.minecraftforge.fml.common.ObfuscationReflectionHelper) MetaItem(gregtech.api.items.metaitem.MetaItem) gregtech.integration.jei.recipe(gregtech.integration.jei.recipe) MultiblockInfoCategory(gregtech.integration.jei.multiblock.MultiblockInfoCategory) MaterialTreeCategory(gregtech.integration.jei.recipe.primitive.MaterialTreeCategory) MetaTileEntity(gregtech.api.metatileentity.MetaTileEntity) Recipe(gregtech.api.recipes.Recipe) OreDepositDefinition(gregtech.api.worldgen.config.OreDepositDefinition) WorldGenRegistry(gregtech.api.worldgen.config.WorldGenRegistry) Collection(java.util.Collection) PropertyKey(gregtech.api.unification.material.properties.PropertyKey) Collectors(java.util.stream.Collectors) IIngredientRegistry(mezz.jei.api.ingredients.IIngredientRegistry) Internal(mezz.jei.Internal) List(java.util.List) Stream(java.util.stream.Stream) VanillaRecipeCategoryUid(mezz.jei.api.recipe.VanillaRecipeCategoryUid) IntCircuitIngredient(gregtech.api.recipes.ingredients.IntCircuitIngredient) Constants(mezz.jei.config.Constants) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) MetaBlocks(gregtech.common.blocks.MetaBlocks) MetaItems(gregtech.common.items.MetaItems) IMultipleRecipeMaps(gregtech.api.capability.IMultipleRecipeMaps) RecipeMapFurnace(gregtech.api.recipes.machines.RecipeMapFurnace) GregtechTileCapabilities(gregtech.api.capability.GregtechTileCapabilities) GregTechAPI(gregtech.api.GregTechAPI) OreByProduct(gregtech.integration.jei.recipe.primitive.OreByProduct) mezz.jei.api(mezz.jei.api) Material(gregtech.api.unification.material.Material) RecipeMap(gregtech.api.recipes.RecipeMap) RecipeMaps(gregtech.api.recipes.RecipeMaps) Nonnull(javax.annotation.Nonnull) AbstractRecipeLogic(gregtech.api.capability.impl.AbstractRecipeLogic) IShowsRecipeFocuses(mezz.jei.input.IShowsRecipeFocuses) MaterialTree(gregtech.integration.jei.recipe.primitive.MaterialTree) InputHandler(mezz.jei.input.InputHandler) IControllable(gregtech.api.capability.IControllable) SteamMetaTileEntity(gregtech.api.metatileentity.SteamMetaTileEntity) CustomItemReturnShapedOreRecipeRecipe(gregtech.loaders.recipe.CustomItemReturnShapedOreRecipeRecipe) Field(java.lang.reflect.Field) GTValues(gregtech.api.GTValues) ResourceLocation(net.minecraft.util.ResourceLocation) VanillaTypes(mezz.jei.api.ingredients.VanillaTypes) CraftingSlotWidget(gregtech.common.gui.widget.craftingstation.CraftingSlotWidget) Recipe(gregtech.api.recipes.Recipe) CustomItemReturnShapedOreRecipeRecipe(gregtech.loaders.recipe.CustomItemReturnShapedOreRecipeRecipe) OreDepositDefinition(gregtech.api.worldgen.config.OreDepositDefinition) OreByProduct(gregtech.integration.jei.recipe.primitive.OreByProduct) CraftingSlotWidget(gregtech.common.gui.widget.craftingstation.CraftingSlotWidget) ResourceLocation(net.minecraft.util.ResourceLocation) AbstractRecipeLogic(gregtech.api.capability.impl.AbstractRecipeLogic) IControllable(gregtech.api.capability.IControllable) Material(gregtech.api.unification.material.Material) MaterialTree(gregtech.integration.jei.recipe.primitive.MaterialTree) MetaTileEntity(gregtech.api.metatileentity.MetaTileEntity) SteamMetaTileEntity(gregtech.api.metatileentity.SteamMetaTileEntity) IMultipleRecipeMaps(gregtech.api.capability.IMultipleRecipeMaps) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList)

Aggregations

Material (gregtech.api.unification.material.Material)76 ItemStack (net.minecraft.item.ItemStack)31 UnificationEntry (gregtech.api.unification.stack.UnificationEntry)19 OrePrefix (gregtech.api.unification.ore.OrePrefix)13 MaterialStack (gregtech.api.unification.stack.MaterialStack)12 Nonnull (javax.annotation.Nonnull)10 PropertyKey (gregtech.api.unification.material.properties.PropertyKey)9 Block (net.minecraft.block.Block)8 IBlockState (net.minecraft.block.state.IBlockState)8 GTValues (gregtech.api.GTValues)7 Collectors (java.util.stream.Collectors)7 Nullable (javax.annotation.Nullable)7 Materials (gregtech.api.unification.material.Materials)6 DustProperty (gregtech.api.unification.material.properties.DustProperty)6 ToolProperty (gregtech.api.unification.material.properties.ToolProperty)6 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)6 GregTechAPI (gregtech.api.GregTechAPI)5 OreDictUnifier (gregtech.api.unification.OreDictUnifier)5 MarkerMaterial (gregtech.api.unification.material.MarkerMaterial)5 ItemMaterialInfo (gregtech.api.unification.stack.ItemMaterialInfo)5