Search in sources :

Example 1 with IItemProvider

use of mekanism.api.providers.IItemProvider in project Mekanism by mekanism.

the class OreProcessingRecipeProvider method addDynamicOreProcessingIngotRecipes.

private void addDynamicOreProcessingIngotRecipes(Consumer<IFinishedRecipe> consumer, String basePath, PrimaryResource resource) {
    net.minecraft.util.IItemProvider ingot = MekanismItems.PROCESSED_RESOURCES.get(ResourceType.INGOT, resource);
    ITag<Item> ingotTag = MekanismTags.Items.PROCESSED_RESOURCES.get(ResourceType.INGOT, resource);
    net.minecraft.util.IItemProvider nugget = MekanismItems.PROCESSED_RESOURCES.get(ResourceType.NUGGET, resource);
    ITag<Item> nuggetTag = MekanismTags.Items.PROCESSED_RESOURCES.get(ResourceType.NUGGET, resource);
    net.minecraft.util.IItemProvider block = MekanismBlocks.PROCESSED_RESOURCE_BLOCKS.get(resource);
    ITag<Item> blockTag = MekanismTags.Items.PROCESSED_RESOURCE_BLOCKS.get(resource);
    net.minecraft.util.IItemProvider ore = MekanismBlocks.ORES.get(OreType.get(resource));
    float dustExperience = 0.3F;
    if (resource == PrimaryResource.IRON) {
        ingot = Items.IRON_INGOT;
        ingotTag = Tags.Items.INGOTS_IRON;
        nugget = Items.IRON_NUGGET;
        nuggetTag = Tags.Items.NUGGETS_IRON;
        block = Blocks.IRON_BLOCK;
        blockTag = Tags.Items.STORAGE_BLOCKS_IRON;
        ore = Blocks.IRON_ORE;
        dustExperience = 0.35F;
    } else if (resource == PrimaryResource.GOLD) {
        ingot = Items.GOLD_INGOT;
        ingotTag = Tags.Items.INGOTS_GOLD;
        nugget = Items.GOLD_NUGGET;
        nuggetTag = Tags.Items.NUGGETS_GOLD;
        block = Blocks.GOLD_BLOCK;
        blockTag = Tags.Items.STORAGE_BLOCKS_GOLD;
        ore = Blocks.GOLD_ORE;
        dustExperience = 0.5F;
    }
    IItemProvider dust = MekanismItems.PROCESSED_RESOURCES.get(ResourceType.DUST, resource);
    IItemProvider dirtyDust = MekanismItems.PROCESSED_RESOURCES.get(ResourceType.DIRTY_DUST, resource);
    IItemProvider clump = MekanismItems.PROCESSED_RESOURCES.get(ResourceType.CLUMP, resource);
    IItemProvider crystal = MekanismItems.PROCESSED_RESOURCES.get(ResourceType.CRYSTAL, resource);
    IItemProvider shard = MekanismItems.PROCESSED_RESOURCES.get(ResourceType.SHARD, resource);
    ITag<Item> dustTag = MekanismTags.Items.PROCESSED_RESOURCES.get(ResourceType.DUST, resource);
    ITag<Item> dirtyDustTag = MekanismTags.Items.PROCESSED_RESOURCES.get(ResourceType.DIRTY_DUST, resource);
    ITag<Item> clumpTag = MekanismTags.Items.PROCESSED_RESOURCES.get(ResourceType.CLUMP, resource);
    ITag<Item> shardTag = MekanismTags.Items.PROCESSED_RESOURCES.get(ResourceType.SHARD, resource);
    ITag<Item> crystalTag = MekanismTags.Items.PROCESSED_RESOURCES.get(ResourceType.CRYSTAL, resource);
    SlurryRegistryObject<?, ?> slurry = MekanismSlurries.PROCESSED_RESOURCES.get(resource);
    // Clump
    // from ore
    ItemStackChemicalToItemStackRecipeBuilder.purifying(ItemStackIngredient.from(resource.getOreTag()), GasStackIngredient.from(MekanismGases.OXYGEN, 1), clump.getItemStack(3)).build(consumer, Mekanism.rl(basePath + "clump/from_ore"));
    // from shard
    ItemStackChemicalToItemStackRecipeBuilder.purifying(ItemStackIngredient.from(shardTag), GasStackIngredient.from(MekanismGases.OXYGEN, 1), clump.getItemStack()).build(consumer, Mekanism.rl(basePath + "clump/from_shard"));
    // Crystal
    // from slurry
    ChemicalCrystallizerRecipeBuilder.crystallizing(SlurryStackIngredient.from(slurry.getCleanSlurry(), 200), crystal.getItemStack()).build(consumer, Mekanism.rl(basePath + "crystal/from_slurry"));
    // Dirty Dust
    // from clump
    ItemStackToItemStackRecipeBuilder.crushing(ItemStackIngredient.from(clumpTag), dirtyDust.getItemStack()).build(consumer, Mekanism.rl(basePath + "dirty_dust/from_clump"));
    // Dust
    // from dirty dust
    ItemStackToItemStackRecipeBuilder.enriching(ItemStackIngredient.from(dirtyDustTag), dust.getItemStack()).build(consumer, Mekanism.rl(basePath + "dust/from_dirty_dust"));
    // from ingot
    ItemStackToItemStackRecipeBuilder.crushing(ItemStackIngredient.from(ingotTag), dust.getItemStack()).build(consumer, Mekanism.rl(basePath + "dust/from_ingot"));
    // from ore
    ItemStackToItemStackRecipeBuilder.enriching(ItemStackIngredient.from(resource.getOreTag()), dust.getItemStack(2)).build(consumer, Mekanism.rl(basePath + "dust/from_ore"));
    // Ingot
    // from dust
    RecipeProviderUtil.addSmeltingBlastingRecipes(consumer, Ingredient.of(dustTag), ingot, dustExperience, 200, Mekanism.rl(basePath + "ingot/from_dust_blasting"), Mekanism.rl(basePath + "ingot/from_dust_smelting"));
    if (!resource.isVanilla()) {
        // from block
        ExtendedShapelessRecipeBuilder.shapelessRecipe(ingot, 9).addIngredient(blockTag).build(consumer, Mekanism.rl(basePath + "ingot/from_block"));
        // to block
        ExtendedShapedRecipeBuilder.shapedRecipe(block).pattern(MekanismRecipeProvider.STORAGE_PATTERN).key(Pattern.CONSTANT, ingotTag).build(consumer, Mekanism.rl(basePath + "storage_blocks/from_ingots"));
        // from nuggets
        ExtendedShapedRecipeBuilder.shapedRecipe(ingot).pattern(MekanismRecipeProvider.STORAGE_PATTERN).key(Pattern.CONSTANT, nuggetTag).build(consumer, Mekanism.rl(basePath + "ingot/from_nuggets"));
        // to nuggets
        ExtendedShapelessRecipeBuilder.shapelessRecipe(nugget, 9).addIngredient(ingotTag).build(consumer, Mekanism.rl(basePath + "nugget/from_ingot"));
        // from ore
        RecipeProviderUtil.addSmeltingBlastingRecipes(consumer, Ingredient.of(resource.getOreTag()), ingot, dustExperience * 2, 200, Mekanism.rl(basePath + "ingot/from_ore_blasting"), Mekanism.rl(basePath + "ingot/from_ore_smelting"));
    }
    // Ore
    // from dust
    CombinerRecipeBuilder.combining(ItemStackIngredient.from(dustTag, 8), ItemStackIngredient.from(Tags.Items.COBBLESTONE), new ItemStack(ore)).build(consumer, Mekanism.rl(basePath + "ore/from_dust"));
    // Shard
    // from crystal
    ItemStackChemicalToItemStackRecipeBuilder.injecting(ItemStackIngredient.from(crystalTag), GasStackIngredient.from(MekanismGases.HYDROGEN_CHLORIDE, 1), shard.getItemStack()).build(consumer, Mekanism.rl(basePath + "shard/from_crystal"));
    // from ore
    ItemStackChemicalToItemStackRecipeBuilder.injecting(ItemStackIngredient.from(resource.getOreTag()), GasStackIngredient.from(MekanismGases.HYDROGEN_CHLORIDE, 1), shard.getItemStack(4)).build(consumer, Mekanism.rl(basePath + "shard/from_ore"));
    // Slurry
    // clean
    FluidSlurryToSlurryRecipeBuilder.washing(FluidStackIngredient.from(FluidTags.WATER, 5), SlurryStackIngredient.from(slurry.getDirtySlurry(), 1), slurry.getCleanSlurry().getStack(1)).build(consumer, Mekanism.rl(basePath + "slurry/clean"));
    // dirty
    ChemicalDissolutionRecipeBuilder.dissolution(ItemStackIngredient.from(resource.getOreTag()), GasStackIngredient.from(MekanismGases.SULFURIC_ACID, 1), slurry.getDirtySlurry().getStack(1_000)).build(consumer, Mekanism.rl(basePath + "slurry/dirty"));
}
Also used : Item(net.minecraft.item.Item) IItemProvider(mekanism.api.providers.IItemProvider) ItemStack(net.minecraft.item.ItemStack)

Example 2 with IItemProvider

use of mekanism.api.providers.IItemProvider in project Mekanism by mekanism.

the class ToolsItemModelProvider method registerModels.

@Override
protected void registerModels() {
    // Shields
    addShieldModel(ToolsItems.BRONZE_SHIELD, Mekanism.rl("block/block_bronze"));
    addShieldModel(ToolsItems.LAPIS_LAZULI_SHIELD, mcLoc("block/lapis_block"));
    addShieldModel(ToolsItems.OSMIUM_SHIELD, Mekanism.rl("block/block_osmium"));
    addShieldModel(ToolsItems.REFINED_GLOWSTONE_SHIELD, Mekanism.rl("block/block_refined_glowstone"));
    addShieldModel(ToolsItems.REFINED_OBSIDIAN_SHIELD, Mekanism.rl("block/block_refined_obsidian"));
    addShieldModel(ToolsItems.STEEL_SHIELD, Mekanism.rl("block/block_steel"));
    // Armor items are generated textures, all other tools module items are handheld
    for (IItemProvider itemProvider : ToolsItems.ITEMS.getAllItems()) {
        Item item = itemProvider.getItem();
        if (item instanceof ItemMekanismShield) {
            // Skip shields, we manually handle them above
            continue;
        }
        ResourceLocation texture;
        if (isVanilla(itemProvider)) {
            texture = itemTexture(itemProvider);
        } else {
            String name = itemProvider.getName();
            int index = name.lastIndexOf('_');
            texture = modLoc("item/" + name.substring(0, index) + '/' + name.substring(index + 1));
        }
        if (item instanceof ArmorItem) {
            generated(itemProvider, texture);
        } else {
            handheld(itemProvider, texture);
        }
    }
}
Also used : Item(net.minecraft.item.Item) ArmorItem(net.minecraft.item.ArmorItem) ArmorItem(net.minecraft.item.ArmorItem) ResourceLocation(net.minecraft.util.ResourceLocation) ItemMekanismShield(mekanism.tools.common.item.ItemMekanismShield) IItemProvider(mekanism.api.providers.IItemProvider)

Example 3 with IItemProvider

use of mekanism.api.providers.IItemProvider in project Mekanism by mekanism.

the class ModuleHelper method mapSupportedModules.

private void mapSupportedModules(String imcMethod, IItemProvider moduleContainer, Map<ModuleData<?>, ImmutableSet.Builder<Item>> supportedContainersBuilderMap) {
    ImmutableSet.Builder<ModuleData<?>> supportedModulesBuilder = ImmutableSet.builder();
    InterModComms.getMessages(Mekanism.MODID, imcMethod::equals).forEach(message -> {
        Object body = message.getMessageSupplier().get();
        if (body instanceof IModuleDataProvider) {
            IModuleDataProvider<?> moduleDataProvider = (IModuleDataProvider<?>) body;
            supportedModulesBuilder.add(moduleDataProvider.getModuleData());
            logDebugReceivedIMC(imcMethod, message.getSenderModId(), moduleDataProvider);
        } else if (body instanceof IModuleDataProvider[]) {
            for (IModuleDataProvider<?> moduleDataProvider : ((IModuleDataProvider<?>[]) body)) {
                supportedModulesBuilder.add(moduleDataProvider.getModuleData());
                logDebugReceivedIMC(imcMethod, message.getSenderModId(), moduleDataProvider);
            }
        } else {
            Mekanism.logger.warn("Received IMC message for '{}' from mod '{}' with an invalid body.", imcMethod, message.getSenderModId());
        }
    });
    Set<ModuleData<?>> supported = supportedModulesBuilder.build();
    if (!supported.isEmpty()) {
        Item item = moduleContainer.getItem();
        supportedModules.put(item, supported);
        for (ModuleData<?> data : supported) {
            supportedContainersBuilderMap.computeIfAbsent(data, d -> ImmutableSet.builder()).add(item);
        }
    }
}
Also used : MekanismAPI(mekanism.api.MekanismAPI) TextUtils(mekanism.common.util.text.TextUtils) OnOff(mekanism.common.util.text.BooleanStateDisplay.OnOff) Item(net.minecraft.item.Item) ICustomModule(mekanism.api.gear.ICustomModule) CompoundNBT(net.minecraft.nbt.CompoundNBT) ParametersAreNonnullByDefault(javax.annotation.ParametersAreNonnullByDefault) ArrayList(java.util.ArrayList) ItemDataUtils(mekanism.common.util.ItemDataUtils) ITextComponent(net.minecraft.util.text.ITextComponent) HashSet(java.util.HashSet) ItemStack(net.minecraft.item.ItemStack) Object2ObjectOpenHashMap(it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap) Map(java.util.Map) MekanismItems(mekanism.common.registries.MekanismItems) InterModComms(net.minecraftforge.fml.InterModComms) Nullable(javax.annotation.Nullable) Mekanism(mekanism.common.Mekanism) IItemProvider(mekanism.api.providers.IItemProvider) ImmutableSet(com.google.common.collect.ImmutableSet) MethodsReturnNonnullByDefault(mcp.MethodsReturnNonnullByDefault) MekanismIMC(mekanism.api.MekanismIMC) IModule(mekanism.api.gear.IModule) Collection(java.util.Collection) Set(java.util.Set) ModuleData(mekanism.api.gear.ModuleData) IModuleHelper(mekanism.api.gear.IModuleHelper) ItemModule(mekanism.common.item.ItemModule) List(java.util.List) NBT(net.minecraftforge.common.util.Constants.NBT) IHUDElement(mekanism.api.gear.IHUDElement) HUDColor(mekanism.api.gear.IHUDElement.HUDColor) NBTConstants(mekanism.api.NBTConstants) ResourceLocation(net.minecraft.util.ResourceLocation) IModuleDataProvider(mekanism.api.providers.IModuleDataProvider) Collections(java.util.Collections) Item(net.minecraft.item.Item) ImmutableSet(com.google.common.collect.ImmutableSet) ModuleData(mekanism.api.gear.ModuleData) IModuleDataProvider(mekanism.api.providers.IModuleDataProvider)

Aggregations

IItemProvider (mekanism.api.providers.IItemProvider)3 Item (net.minecraft.item.Item)3 ItemStack (net.minecraft.item.ItemStack)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 Object2ObjectOpenHashMap (it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Nullable (javax.annotation.Nullable)1 ParametersAreNonnullByDefault (javax.annotation.ParametersAreNonnullByDefault)1 MethodsReturnNonnullByDefault (mcp.MethodsReturnNonnullByDefault)1 MekanismAPI (mekanism.api.MekanismAPI)1 MekanismIMC (mekanism.api.MekanismIMC)1 NBTConstants (mekanism.api.NBTConstants)1 ICustomModule (mekanism.api.gear.ICustomModule)1