Search in sources :

Example 1 with IDisplayableCastingRecipe

use of slimeknights.tconstruct.library.recipe.casting.IDisplayableCastingRecipe in project TinkersConstruct by SlimeKnights.

the class ContentMaterialSkull method getSkullRecipe.

/**
 * Gets the recipe to cast this skull
 */
@Nullable
private IDisplayableCastingRecipe getSkullRecipe() {
    Level world = Minecraft.getInstance().level;
    if (!searchedSkullRecipe && world != null) {
        skullRecipe = world.getRecipeManager().getAllRecipesFor(RecipeTypes.CASTING_BASIN).stream().filter(recipe -> recipe instanceof IDisplayableCastingRecipe).map(recipe -> (IDisplayableCastingRecipe) recipe).filter(recipe -> {
            ItemStack output = recipe.getOutput();
            return output.getItem() == TinkerTools.slimesuit.get(ArmorSlotType.HELMET) && MaterialIdNBT.from(output).getMaterial(0).getId().toString().equals(materialName);
        }).findFirst().orElse(null);
        searchedSkullRecipe = true;
    }
    return skullRecipe;
}
Also used : MaterialStatsId(slimeknights.tconstruct.library.materials.stats.MaterialStatsId) TextElement(slimeknights.mantle.client.screen.book.element.TextElement) BookData(slimeknights.mantle.client.book.data.BookData) ArrayList(java.util.ArrayList) TextData(slimeknights.mantle.client.book.data.element.TextData) I18n(net.minecraft.client.resources.language.I18n) ImmutableList(com.google.common.collect.ImmutableList) ArmorSlotType(slimeknights.tconstruct.tools.item.ArmorSlotType) Minecraft(net.minecraft.client.Minecraft) TinkerToolParts(slimeknights.tconstruct.tools.TinkerToolParts) TranslatableComponent(net.minecraft.network.chat.TranslatableComponent) Nullable(javax.annotation.Nullable) RecipeTypes(slimeknights.tconstruct.library.recipe.RecipeTypes) BookScreen(slimeknights.mantle.client.screen.book.BookScreen) ItemElement(slimeknights.mantle.client.screen.book.element.ItemElement) Component(net.minecraft.network.chat.Component) TinkerTools(slimeknights.tconstruct.tools.TinkerTools) MaterialVariantId(slimeknights.tconstruct.library.materials.definition.MaterialVariantId) MaterialTooltipCache(slimeknights.tconstruct.library.client.materials.MaterialTooltipCache) TConstruct(slimeknights.tconstruct.TConstruct) TinkerItemElement(slimeknights.tconstruct.library.client.book.elements.TinkerItemElement) SkullStats(slimeknights.tconstruct.tools.stats.SkullStats) List(java.util.List) MaterialId(slimeknights.tconstruct.library.materials.definition.MaterialId) IDisplayableCastingRecipe(slimeknights.tconstruct.library.recipe.casting.IDisplayableCastingRecipe) ForgeI18n(net.minecraftforge.common.ForgeI18n) ItemStack(net.minecraft.world.item.ItemStack) Level(net.minecraft.world.level.Level) MaterialIdNBT(slimeknights.tconstruct.library.tools.nbt.MaterialIdNBT) BookElement(slimeknights.mantle.client.screen.book.element.BookElement) Level(net.minecraft.world.level.Level) IDisplayableCastingRecipe(slimeknights.tconstruct.library.recipe.casting.IDisplayableCastingRecipe) ItemStack(net.minecraft.world.item.ItemStack) Nullable(javax.annotation.Nullable)

Example 2 with IDisplayableCastingRecipe

use of slimeknights.tconstruct.library.recipe.casting.IDisplayableCastingRecipe in project TinkersConstruct by SlimeKnights.

the class JEIPlugin method registerRecipes.

@Override
public void registerRecipes(IRecipeRegistration register) {
    assert Minecraft.getInstance().level != null;
    RecipeManager manager = Minecraft.getInstance().level.getRecipeManager();
    // casting
    List<IDisplayableCastingRecipe> castingBasinRecipes = RecipeHelper.getJEIRecipes(manager, RecipeTypes.CASTING_BASIN, IDisplayableCastingRecipe.class);
    register.addRecipes(castingBasinRecipes, TConstructRecipeCategoryUid.castingBasin);
    List<IDisplayableCastingRecipe> castingTableRecipes = RecipeHelper.getJEIRecipes(manager, RecipeTypes.CASTING_TABLE, IDisplayableCastingRecipe.class);
    register.addRecipes(castingTableRecipes, TConstructRecipeCategoryUid.castingTable);
    // melting
    List<MeltingRecipe> meltingRecipes = RecipeHelper.getJEIRecipes(manager, RecipeTypes.MELTING, MeltingRecipe.class);
    register.addRecipes(meltingRecipes, TConstructRecipeCategoryUid.melting);
    register.addRecipes(meltingRecipes, TConstructRecipeCategoryUid.foundry);
    MeltingFuelHandler.setMeltngFuels(RecipeHelper.getRecipes(manager, RecipeTypes.FUEL, MeltingFuel.class));
    // entity melting
    List<EntityMeltingRecipe> entityMeltingRecipes = RecipeHelper.getJEIRecipes(manager, RecipeTypes.ENTITY_MELTING, EntityMeltingRecipe.class);
    // generate a "default" recipe for all other entity types
    entityMeltingRecipes.add(new DefaultEntityMeltingRecipe(entityMeltingRecipes));
    register.addRecipes(entityMeltingRecipes, TConstructRecipeCategoryUid.entityMelting);
    // alloying
    List<AlloyRecipe> alloyRecipes = RecipeHelper.getJEIRecipes(manager, RecipeTypes.ALLOYING, AlloyRecipe.class);
    register.addRecipes(alloyRecipes, TConstructRecipeCategoryUid.alloy);
    // molding
    List<MoldingRecipe> moldingRecipes = ImmutableList.<MoldingRecipe>builder().addAll(RecipeHelper.getJEIRecipes(manager, RecipeTypes.MOLDING_TABLE, MoldingRecipe.class)).addAll(RecipeHelper.getJEIRecipes(manager, RecipeTypes.MOLDING_BASIN, MoldingRecipe.class)).build();
    register.addRecipes(moldingRecipes, TConstructRecipeCategoryUid.molding);
    // modifiers
    List<IDisplayModifierRecipe> modifierRecipes = RecipeHelper.getJEIRecipes(manager, RecipeTypes.TINKER_STATION, IDisplayModifierRecipe.class).stream().sorted((r1, r2) -> {
        SlotType t1 = r1.getSlotType();
        SlotType t2 = r2.getSlotType();
        String n1 = t1 == null ? "zzzzzzzzzz" : t1.getName();
        String n2 = t2 == null ? "zzzzzzzzzz" : t2.getName();
        return n1.compareTo(n2);
    }).collect(Collectors.toList());
    register.addRecipes(modifierRecipes, TConstructRecipeCategoryUid.modifiers);
    // beheading
    List<SeveringRecipe> severingRecipes = RecipeHelper.getJEIRecipes(manager, RecipeTypes.SEVERING, SeveringRecipe.class);
    register.addRecipes(severingRecipes, TConstructRecipeCategoryUid.severing);
    // part builder
    List<MaterialRecipe> materialRecipes = RecipeHelper.getRecipes(manager, RecipeTypes.MATERIAL, MaterialRecipe.class);
    MaterialItemList.setRecipes(materialRecipes);
    List<IDisplayPartBuilderRecipe> partRecipes = RecipeHelper.getJEIRecipes(manager, RecipeTypes.PART_BUILDER, IDisplayPartBuilderRecipe.class);
    register.addRecipes(partRecipes, TConstructRecipeCategoryUid.partBuilder);
}
Also used : HeatingStructureScreen(slimeknights.tconstruct.smeltery.client.screen.HeatingStructureScreen) Item(net.minecraft.world.item.Item) MeltingFuel(slimeknights.tconstruct.library.recipe.fuel.MeltingFuel) RecipeHelper(slimeknights.mantle.recipe.helper.RecipeHelper) Config(slimeknights.tconstruct.common.config.Config) UidContext(mezz.jei.api.ingredients.subtypes.UidContext) IGuiHelper(mezz.jei.api.helpers.IGuiHelper) SlotType(slimeknights.tconstruct.library.tools.SlotType) CastItemObject(slimeknights.tconstruct.common.registration.CastItemObject) CastingTableCategory(slimeknights.tconstruct.plugin.jei.casting.CastingTableCategory) ArmorSlotType(slimeknights.tconstruct.tools.item.ArmorSlotType) RecipeType(net.minecraft.world.item.crafting.RecipeType) VanillaRecipeCategoryUid(mezz.jei.api.constants.VanillaRecipeCategoryUid) ModList(net.minecraftforge.fml.ModList) IGuiHandlerRegistration(mezz.jei.api.registration.IGuiHandlerRegistration) IGuiContainerHandler(mezz.jei.api.gui.handlers.IGuiContainerHandler) TinkerTools(slimeknights.tconstruct.tools.TinkerTools) AlloyRecipe(slimeknights.tconstruct.library.recipe.alloying.AlloyRecipe) SeveringCategory(slimeknights.tconstruct.plugin.jei.entity.SeveringCategory) IDisplayableCastingRecipe(slimeknights.tconstruct.library.recipe.casting.IDisplayableCastingRecipe) IMaterialItem(slimeknights.tconstruct.library.tools.part.IMaterialItem) IIngredientType(mezz.jei.api.ingredients.IIngredientType) Modifier(slimeknights.tconstruct.library.modifiers.Modifier) FluidStack(net.minecraftforge.fluids.FluidStack) CastingBasinCategory(slimeknights.tconstruct.plugin.jei.casting.CastingBasinCategory) ItemStack(net.minecraft.world.item.ItemStack) MaterialIdNBT(slimeknights.tconstruct.library.tools.nbt.MaterialIdNBT) IRecipeCatalystRegistration(mezz.jei.api.registration.IRecipeCatalystRegistration) IDisplayModifierRecipe(slimeknights.tconstruct.library.recipe.modifiers.adding.IDisplayModifierRecipe) MeltingRecipe(slimeknights.tconstruct.library.recipe.melting.MeltingRecipe) EntityType(net.minecraft.world.entity.EntityType) AbstractContainerMenu(net.minecraft.world.inventory.AbstractContainerMenu) ModifierBookmarkIngredientRenderer(slimeknights.tconstruct.plugin.jei.modifiers.ModifierBookmarkIngredientRenderer) TinkerModifiers(slimeknights.tconstruct.tools.TinkerModifiers) IModPlugin(mezz.jei.api.IModPlugin) Container(net.minecraft.world.Container) EntityIngredientRenderer(slimeknights.tconstruct.plugin.jei.entity.EntityIngredientRenderer) IModifiableDisplay(slimeknights.tconstruct.library.tools.item.IModifiableDisplay) IModIngredientRegistration(mezz.jei.api.registration.IModIngredientRegistration) IRecipeTransferRegistration(mezz.jei.api.registration.IRecipeTransferRegistration) CopperCanItem(slimeknights.tconstruct.smeltery.item.CopperCanItem) MeltingCategory(slimeknights.tconstruct.plugin.jei.melting.MeltingCategory) Nullable(javax.annotation.Nullable) RecipeTypes(slimeknights.tconstruct.library.recipe.RecipeTypes) MelterScreen(slimeknights.tconstruct.smeltery.client.screen.MelterScreen) DefaultEntityMeltingRecipe(slimeknights.tconstruct.plugin.jei.entity.DefaultEntityMeltingRecipe) Tag(net.minecraft.tags.Tag) MaterialVariantId(slimeknights.tconstruct.library.materials.definition.MaterialVariantId) Pattern(slimeknights.tconstruct.library.recipe.partbuilder.Pattern) IScreenWithFluidTank(slimeknights.tconstruct.smeltery.client.screen.IScreenWithFluidTank) TinkerSmeltery(slimeknights.tconstruct.smeltery.TinkerSmeltery) RetexturedBlockItem(slimeknights.mantle.item.RetexturedBlockItem) MoldingRecipe(slimeknights.tconstruct.library.recipe.molding.MoldingRecipe) ModifierIngredientHelper(slimeknights.tconstruct.plugin.jei.modifiers.ModifierIngredientHelper) ResourceLocation(net.minecraft.resources.ResourceLocation) PatternIngredientHelper(slimeknights.tconstruct.plugin.jei.partbuilder.PatternIngredientHelper) EntityIngredientHelper(slimeknights.tconstruct.plugin.jei.entity.EntityIngredientHelper) FluidAttributes(net.minecraftforge.fluids.FluidAttributes) EntityMeltingRecipeCategory(slimeknights.tconstruct.plugin.jei.entity.EntityMeltingRecipeCategory) Registry(net.minecraft.core.Registry) IIngredientManager(mezz.jei.api.runtime.IIngredientManager) CreativeSlotItem(slimeknights.tconstruct.tools.item.CreativeSlotItem) IDisplayPartBuilderRecipe(slimeknights.tconstruct.library.recipe.partbuilder.IDisplayPartBuilderRecipe) ModifierEntry(slimeknights.tconstruct.library.modifiers.ModifierEntry) MeltingFuelHandler(slimeknights.tconstruct.plugin.jei.melting.MeltingFuelHandler) PartBuilderCategory(slimeknights.tconstruct.plugin.jei.partbuilder.PartBuilderCategory) EntityMeltingRecipe(slimeknights.tconstruct.library.recipe.entitymelting.EntityMeltingRecipe) IMaterial(slimeknights.tconstruct.library.materials.definition.IMaterial) TinkerTables(slimeknights.tconstruct.tables.TinkerTables) TinkerTags(slimeknights.tconstruct.common.TinkerTags) IRecipeCategoryRegistration(mezz.jei.api.registration.IRecipeCategoryRegistration) Collectors(java.util.stream.Collectors) List(java.util.List) FoundryCategory(slimeknights.tconstruct.plugin.jei.melting.FoundryCategory) RecipeManager(net.minecraft.world.item.crafting.RecipeManager) IIngredientSubtypeInterpreter(mezz.jei.api.ingredients.subtypes.IIngredientSubtypeInterpreter) ISubtypeRegistration(mezz.jei.api.registration.ISubtypeRegistration) MaterialRecipe(slimeknights.tconstruct.library.recipe.material.MaterialRecipe) VanillaTypes(mezz.jei.api.constants.VanillaTypes) IJeiRuntime(mezz.jei.api.runtime.IJeiRuntime) AbstractContainerScreen(net.minecraft.client.gui.screens.inventory.AbstractContainerScreen) SeveringRecipe(slimeknights.tconstruct.library.recipe.modifiers.severing.SeveringRecipe) JeiPlugin(mezz.jei.api.JeiPlugin) ImmutableList(com.google.common.collect.ImmutableList) Minecraft(net.minecraft.client.Minecraft) ItemLike(net.minecraft.world.level.ItemLike) IRecipeRegistration(mezz.jei.api.registration.IRecipeRegistration) Fluid(net.minecraft.world.level.material.Fluid) TinkerMaterials(slimeknights.tconstruct.shared.TinkerMaterials) SerializationTags(net.minecraft.tags.SerializationTags) PatternIngredientRenderer(slimeknights.tconstruct.plugin.jei.partbuilder.PatternIngredientRenderer) TinkerFluids(slimeknights.tconstruct.fluids.TinkerFluids) MaterialItemList(slimeknights.tconstruct.plugin.jei.partbuilder.MaterialItemList) SmelteryCompat(slimeknights.tconstruct.smeltery.data.SmelteryCompat) Recipe(net.minecraft.world.item.crafting.Recipe) ModifierRecipeCategory(slimeknights.tconstruct.plugin.jei.modifiers.ModifierRecipeCategory) Comparator(java.util.Comparator) Collections(java.util.Collections) TinkerStationTransferInfo(slimeknights.tconstruct.plugin.jei.transfer.TinkerStationTransferInfo) MeltingFuel(slimeknights.tconstruct.library.recipe.fuel.MeltingFuel) DefaultEntityMeltingRecipe(slimeknights.tconstruct.plugin.jei.entity.DefaultEntityMeltingRecipe) EntityMeltingRecipe(slimeknights.tconstruct.library.recipe.entitymelting.EntityMeltingRecipe) IDisplayModifierRecipe(slimeknights.tconstruct.library.recipe.modifiers.adding.IDisplayModifierRecipe) IDisplayableCastingRecipe(slimeknights.tconstruct.library.recipe.casting.IDisplayableCastingRecipe) MoldingRecipe(slimeknights.tconstruct.library.recipe.molding.MoldingRecipe) MaterialRecipe(slimeknights.tconstruct.library.recipe.material.MaterialRecipe) SlotType(slimeknights.tconstruct.library.tools.SlotType) ArmorSlotType(slimeknights.tconstruct.tools.item.ArmorSlotType) MeltingRecipe(slimeknights.tconstruct.library.recipe.melting.MeltingRecipe) DefaultEntityMeltingRecipe(slimeknights.tconstruct.plugin.jei.entity.DefaultEntityMeltingRecipe) EntityMeltingRecipe(slimeknights.tconstruct.library.recipe.entitymelting.EntityMeltingRecipe) AlloyRecipe(slimeknights.tconstruct.library.recipe.alloying.AlloyRecipe) SeveringRecipe(slimeknights.tconstruct.library.recipe.modifiers.severing.SeveringRecipe) RecipeManager(net.minecraft.world.item.crafting.RecipeManager) DefaultEntityMeltingRecipe(slimeknights.tconstruct.plugin.jei.entity.DefaultEntityMeltingRecipe) IDisplayPartBuilderRecipe(slimeknights.tconstruct.library.recipe.partbuilder.IDisplayPartBuilderRecipe)

Example 3 with IDisplayableCastingRecipe

use of slimeknights.tconstruct.library.recipe.casting.IDisplayableCastingRecipe in project TinkersConstruct by SlimeKnights.

the class ContentMaterialSkull method addPrimaryDisplayItems.

@Override
protected void addPrimaryDisplayItems(List<ItemElement> displayTools, MaterialVariantId materialId) {
    displayTools.add(new TinkerItemElement(TinkerToolParts.repairKit.get().withMaterialForDisplay(materialId)));
    super.addPrimaryDisplayItems(displayTools, materialId);
    // add skull recipe to display items
    IDisplayableCastingRecipe skullRecipe = getSkullRecipe();
    if (skullRecipe != null) {
        // add repair kit
        List<ItemStack> casts = skullRecipe.getCastItems();
        if (!casts.isEmpty()) {
            ItemElement elementItem = new TinkerItemElement(0, 0, 1, casts);
            elementItem.tooltip = ImmutableList.of(new TranslatableComponent(SKULL_FROM, casts.get(0).getHoverName()));
            displayTools.add(elementItem);
        }
    }
}
Also used : ItemElement(slimeknights.mantle.client.screen.book.element.ItemElement) TinkerItemElement(slimeknights.tconstruct.library.client.book.elements.TinkerItemElement) TranslatableComponent(net.minecraft.network.chat.TranslatableComponent) TinkerItemElement(slimeknights.tconstruct.library.client.book.elements.TinkerItemElement) IDisplayableCastingRecipe(slimeknights.tconstruct.library.recipe.casting.IDisplayableCastingRecipe) ItemStack(net.minecraft.world.item.ItemStack)

Aggregations

ItemStack (net.minecraft.world.item.ItemStack)3 IDisplayableCastingRecipe (slimeknights.tconstruct.library.recipe.casting.IDisplayableCastingRecipe)3 ImmutableList (com.google.common.collect.ImmutableList)2 List (java.util.List)2 Nullable (javax.annotation.Nullable)2 Minecraft (net.minecraft.client.Minecraft)2 TranslatableComponent (net.minecraft.network.chat.TranslatableComponent)2 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 Collectors (java.util.stream.Collectors)1 IModPlugin (mezz.jei.api.IModPlugin)1 JeiPlugin (mezz.jei.api.JeiPlugin)1 VanillaRecipeCategoryUid (mezz.jei.api.constants.VanillaRecipeCategoryUid)1 VanillaTypes (mezz.jei.api.constants.VanillaTypes)1 IGuiContainerHandler (mezz.jei.api.gui.handlers.IGuiContainerHandler)1 IGuiHelper (mezz.jei.api.helpers.IGuiHelper)1 IIngredientType (mezz.jei.api.ingredients.IIngredientType)1 IIngredientSubtypeInterpreter (mezz.jei.api.ingredients.subtypes.IIngredientSubtypeInterpreter)1 UidContext (mezz.jei.api.ingredients.subtypes.UidContext)1