Search in sources :

Example 56 with Material

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

the class RecipeMap method setFoundInvalidRecipe.

public static void setFoundInvalidRecipe(boolean foundInvalidRecipe) {
    RecipeMap.foundInvalidRecipe |= foundInvalidRecipe;
    OrePrefix currentOrePrefix = OrePrefix.getCurrentProcessingPrefix();
    if (currentOrePrefix != null) {
        Material currentMaterial = OrePrefix.getCurrentMaterial();
        GTLog.logger.error("Error happened during processing ore registration of prefix {} and material {}. " + "Seems like cross-mod compatibility issue. Report to GTCEu github.", currentOrePrefix, currentMaterial);
    }
}
Also used : OrePrefix(gregtech.api.unification.ore.OrePrefix) Material(gregtech.api.unification.material.Material)

Example 57 with Material

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

the class ModHandler method removeSmeltingEBFMetals.

/* Note: If a Furnace recipe is added through CT that is the exact same as one of the recipes that will be removed
       then this recipe will not be added. Forge will prevent the duplicate smelting recipe from being added before we
       remove the recipe added by another mod, therefore the CT recipe will fail. At this point, disable the config and
       remove the recipes manually
     */
public static void removeSmeltingEBFMetals() {
    boolean isCTLoaded = Loader.isModLoaded(GTValues.MODID_CT);
    Field actionAddFurnaceRecipe$output = null;
    Map<ItemStack, ItemStack> furnaceList = FurnaceRecipes.instance().getSmeltingList();
    Iterator<Map.Entry<ItemStack, ItemStack>> recipeIterator = furnaceList.entrySet().iterator();
    outer: while (recipeIterator.hasNext()) {
        Map.Entry<ItemStack, ItemStack> recipe = recipeIterator.next();
        ItemStack output = recipe.getValue();
        ItemStack input = recipe.getKey();
        MaterialStack ms = OreDictUnifier.getMaterial(output);
        if (ms != null) {
            Material material = ms.material;
            if (material.hasProperty(PropertyKey.BLAST)) {
                ItemStack dust = OreDictUnifier.get(OrePrefix.dust, material);
                ItemStack ingot = OreDictUnifier.get(OrePrefix.ingot, material);
                // Check if the inputs are actually dust -> ingot
                if (ingot.isItemEqual(output) && dust.isItemEqual(input)) {
                    if (isCTLoaded) {
                        if (actionAddFurnaceRecipe$output == null) {
                            try {
                                actionAddFurnaceRecipe$output = ActionAddFurnaceRecipe.class.getDeclaredField("output");
                                actionAddFurnaceRecipe$output.setAccessible(true);
                            } catch (NoSuchFieldException e) {
                                e.printStackTrace();
                            }
                        }
                        for (ActionAddFurnaceRecipe aafr : MCFurnaceManager.recipesToAdd) {
                            try {
                                // ..was a cached stack in an existing ActionAddFurnaceRecipe as well
                                if (actionAddFurnaceRecipe$output.get(aafr) == output) {
                                    if (ConfigHolder.misc.debug) {
                                        GTLog.logger.info("Not removing Smelting Recipe for EBF material {} as it is added via CT", LocalizationUtils.format(material.getUnlocalizedName()));
                                    }
                                    continue outer;
                                }
                            } catch (IllegalAccessException e) {
                                e.printStackTrace();
                            }
                        }
                    }
                    recipeIterator.remove();
                    if (ConfigHolder.misc.debug) {
                        GTLog.logger.info("Removing Smelting Recipe for EBF material {}", LocalizationUtils.format(material.getUnlocalizedName()));
                    }
                }
            }
        }
    }
}
Also used : Field(java.lang.reflect.Field) UnificationEntry(gregtech.api.unification.stack.UnificationEntry) MaterialStack(gregtech.api.unification.stack.MaterialStack) MarkerMaterial(gregtech.api.unification.material.MarkerMaterial) Material(gregtech.api.unification.material.Material) ActionAddFurnaceRecipe(crafttweaker.mc1120.actions.ActionAddFurnaceRecipe) ItemStack(net.minecraft.item.ItemStack)

Example 58 with Material

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

the class OreConfigUtils method getOreForMaterial.

public static Map<StoneType, IBlockState> getOreForMaterial(Material material) {
    List<BlockOre> oreBlocks = MetaBlocks.ORES.stream().filter(ore -> ore.material == material).collect(Collectors.toList());
    HashMap<StoneType, IBlockState> stoneTypeMap = new HashMap<>();
    for (BlockOre blockOre : oreBlocks) {
        for (StoneType stoneType : blockOre.STONE_TYPE.getAllowedValues()) {
            IBlockState blockState = blockOre.getOreBlock(stoneType);
            stoneTypeMap.put(stoneType, blockState);
        }
    }
    if (stoneTypeMap.isEmpty()) {
        throw new IllegalArgumentException("There is no ore generated for material " + material);
    }
    return stoneTypeMap;
}
Also used : JsonObject(com.google.gson.JsonObject) OreDictUnifier(gregtech.api.unification.OreDictUnifier) Blocks(net.minecraft.init.Blocks) BlockOre(gregtech.common.blocks.BlockOre) MetaBlocks(gregtech.common.blocks.MetaBlocks) PropertyKey(gregtech.api.unification.material.properties.PropertyKey) GameRegistry(net.minecraftforge.fml.common.registry.GameRegistry) HashMap(java.util.HashMap) StoneType(gregtech.api.unification.ore.StoneType) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) JsonElement(com.google.gson.JsonElement) IBlockState(net.minecraft.block.state.IBlockState) ItemStack(net.minecraft.item.ItemStack) JsonArray(com.google.gson.JsonArray) List(java.util.List) GregTechAPI(gregtech.api.GregTechAPI) Block(net.minecraft.block.Block) Map(java.util.Map) ResourceLocation(net.minecraft.util.ResourceLocation) Material(gregtech.api.unification.material.Material) IBlockState(net.minecraft.block.state.IBlockState) HashMap(java.util.HashMap) StoneType(gregtech.api.unification.ore.StoneType) BlockOre(gregtech.common.blocks.BlockOre)

Example 59 with Material

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

the class OreConfigUtils method getOreStateMap.

public static Map<StoneType, IBlockState> getOreStateMap(String stringDeclaration) {
    String materialName;
    if (stringDeclaration.startsWith("ore:")) {
        materialName = stringDeclaration.substring(4);
    } else {
        throw new IllegalArgumentException("Invalid string ore declaration: " + stringDeclaration);
    }
    Material material = getMaterialByName(materialName);
    return getOreForMaterial(material);
}
Also used : Material(gregtech.api.unification.material.Material)

Example 60 with Material

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

the class CommonProxy method createOreBlock.

private static void createOreBlock(Material material, StoneType[] stoneTypes, int index) {
    BlockOre block = new BlockOre(material, stoneTypes);
    block.setRegistryName("ore_" + material + "_" + index);
    for (StoneType stoneType : stoneTypes) {
        GregTechAPI.oreBlockTable.computeIfAbsent(material, m -> new HashMap<>()).put(stoneType, block);
    }
    ORES.add(block);
}
Also used : ModHandler(gregtech.api.recipes.ModHandler) Arrays(java.util.Arrays) BlockItemPipe(gregtech.common.pipelike.itempipe.BlockItemPipe) Loader(net.minecraftforge.fml.common.Loader) MetaItemBracketHandler(gregtech.api.recipes.crafttweaker.MetaItemBracketHandler) Item(net.minecraft.item.Item) ConfigChangedEvent(net.minecraftforge.fml.client.event.ConfigChangedEvent) FurnaceFuelBurnTimeEvent(net.minecraftforge.event.furnace.FurnaceFuelBurnTimeEvent) Materials(gregtech.api.unification.material.Materials) StoneType(gregtech.api.unification.ore.StoneType) TemperatureProperty(gregtech.api.recipes.recipeproperties.TemperatureProperty) Block(net.minecraft.block.Block) CriteriaTriggers(net.minecraft.advancements.CriteriaTriggers) ObfuscationReflectionHelper(net.minecraftforge.fml.common.ObfuscationReflectionHelper) Side(net.minecraftforge.fml.relauncher.Side) MetaItem(gregtech.api.items.metaitem.MetaItem) ItemBlockItemPipe(gregtech.common.pipelike.itempipe.ItemBlockItemPipe) DustProperty(gregtech.api.unification.material.properties.DustProperty) RegistryEvent(net.minecraftforge.event.RegistryEvent) Method(java.lang.reflect.Method) ItemBlockFluidPipe(gregtech.common.pipelike.fluidpipe.ItemBlockFluidPipe) EnchantmentEnderDamage(gregtech.api.enchants.EnchantmentEnderDamage) PropertyKey(gregtech.api.unification.material.properties.PropertyKey) IForgeRegistry(net.minecraftforge.registries.IForgeRegistry) EnchantmentHardHammer(gregtech.api.enchants.EnchantmentHardHammer) FMLLoadCompleteEvent(net.minecraftforge.fml.common.event.FMLLoadCompleteEvent) InvocationTargetException(java.lang.reflect.InvocationTargetException) EventPriority(net.minecraftforge.fml.common.eventhandler.EventPriority) GTTriggers(gregtech.common.advancement.GTTriggers) GTJeiPlugin(gregtech.integration.jei.GTJeiPlugin) Enchantment(net.minecraft.enchantment.Enchantment) ItemBlockCable(gregtech.common.pipelike.cable.ItemBlockCable) gregtech.common.blocks(gregtech.common.blocks) MetaBlocks(gregtech.common.blocks.MetaBlocks) FluidPipeProperties(gregtech.api.unification.material.properties.FluidPipeProperties) MetaItems(gregtech.common.items.MetaItems) ArrayUtils(org.apache.commons.lang3.ArrayUtils) HashMap(java.util.HashMap) Function(java.util.function.Function) TerminalRegistry(gregtech.api.terminal.TerminalRegistry) Type(net.minecraftforge.common.config.Config.Type) ItemStack(net.minecraft.item.ItemStack) GTRecipeManager(gregtech.loaders.recipe.GTRecipeManager) GregTechAPI(gregtech.api.GregTechAPI) MaterialInfoLoader(gregtech.loaders.MaterialInfoLoader) Material(gregtech.api.unification.material.Material) Mod(net.minecraftforge.fml.common.Mod) OrePrefix(gregtech.api.unification.ore.OrePrefix) BlockCable(gregtech.common.pipelike.cable.BlockCable) MachineItemBlock(gregtech.api.block.machines.MachineItemBlock) GTTrigger(gregtech.api.util.advancement.GTTrigger) IRecipe(net.minecraft.item.crafting.IRecipe) GTLog(gregtech.api.util.GTLog) CraftingComponent(gregtech.loaders.recipe.CraftingComponent) FusionEUToStartProperty(gregtech.api.recipes.recipeproperties.FusionEUToStartProperty) BlockFluidPipe(gregtech.common.pipelike.fluidpipe.BlockFluidPipe) MinecraftForge(net.minecraftforge.common.MinecraftForge) GTValues(gregtech.api.GTValues) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) ItemBlock(net.minecraft.item.ItemBlock) ICriterionTrigger(net.minecraft.advancements.ICriterionTrigger) ConfigManager(net.minecraftforge.common.config.ConfigManager) OreDictionaryLoader(gregtech.loaders.OreDictionaryLoader) HashMap(java.util.HashMap) StoneType(gregtech.api.unification.ore.StoneType)

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