Search in sources :

Example 1 with AnvilRecipe

use of net.dries007.tfc.common.recipes.AnvilRecipe in project firmalife by eerussianguy.

the class TFCRegistry method onRegisterAnvilRecipes.

@SubscribeEvent
public static void onRegisterAnvilRecipes(RegistryEvent.Register<AnvilRecipe> event) {
    IForgeRegistry<AnvilRecipe> r = event.getRegistry();
    for (Metal metal : TFCRegistries.METALS.getValuesCollection()) {
        if (metal.isToolMetal())
            r.register(new AnvilRecipe(new ResourceLocation(MOD_ID, metal.toString() + "_mallet_head"), IIngredient.of(new ItemStack(ItemMetal.get(metal, Metal.ItemType.INGOT))), new ItemStack(ItemsFL.getMetalMalletHead(metal)), metal.getTier(), TOOLS, PUNCH_LAST, PUNCH_SECOND_LAST, SHRINK_THIRD_LAST));
    }
    r.registerAll(new AnvilRecipe(new ResourceLocation(MOD_ID, "greenhouse_wall"), IIngredient.of(ItemMetal.get(Metal.WROUGHT_IRON, Metal.ItemType.SHEET)), new ItemStack(BlocksFL.GREENHOUSE_WALL, 2), Metal.WROUGHT_IRON.getTier(), GENERAL, HIT_NOT_LAST, PUNCH_NOT_LAST, SHRINK_LAST));
    r.registerAll(new AnvilRecipe(new ResourceLocation(MOD_ID, "greenhouse_roof"), IIngredient.of(ItemMetal.get(Metal.WROUGHT_IRON, Metal.ItemType.SHEET)), new ItemStack(BlocksFL.GREENHOUSE_ROOF, 2), Metal.WROUGHT_IRON.getTier(), GENERAL, HIT_THIRD_LAST, PUNCH_SECOND_LAST, PUNCH_LAST));
    r.registerAll(new AnvilRecipe(new ResourceLocation(MOD_ID, "greenhouse_door"), IIngredient.of(ItemMetal.get(Metal.WROUGHT_IRON, Metal.ItemType.SHEET)), new ItemStack(ItemsFL.ITEM_GREENHOUSE_DOOR), Metal.WROUGHT_IRON.getTier(), GENERAL, HIT_NOT_LAST, HIT_NOT_LAST, PUNCH_LAST));
    r.registerAll(new AnvilRecipe(new ResourceLocation(MOD_ID, "spout"), IIngredient.of("ingotBlackSteel"), new ItemStack(BlocksFL.SPOUT), Metal.WROUGHT_IRON.getTier(), GENERAL, PUNCH_THIRD_LAST, SHRINK_SECOND_LAST, HIT_LAST));
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) AnvilRecipe(net.dries007.tfc.api.recipes.anvil.AnvilRecipe) Metal(net.dries007.tfc.api.types.Metal) ItemMetal(net.dries007.tfc.objects.items.metal.ItemMetal) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 2 with AnvilRecipe

use of net.dries007.tfc.common.recipes.AnvilRecipe in project TerraFirmaCraft by TerraFirmaCraft.

the class AnvilPlanScreen method init.

@Override
protected void init() {
    super.init();
    final int recipesPerPage = 18;
    final int guiLeft = getGuiLeft(), guiTop = getGuiTop();
    final ItemStack inputStack = blockEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null).map(t -> t.getStackInSlot(AnvilBlockEntity.SLOT_INPUT_MAIN)).orElse(ItemStack.EMPTY);
    final List<AnvilRecipe> recipes = AnvilRecipe.getAll(playerInventory.player.level, inputStack, blockEntity.getTier());
    recipeButtons = new ArrayList<>();
    for (int i = 0; i < recipes.size(); i++) {
        final int page = i / recipesPerPage;
        final int index = i % recipesPerPage;
        final int posX = 7 + (index % 9) * 18;
        final int posY = 25 + ((index % 18) / 9) * 18;
        final AnvilRecipe recipe = recipes.get(i);
        final AnvilPlanSelectButton button = new AnvilPlanSelectButton(guiLeft + posX, guiTop + posY, page, recipe, RenderHelpers.makeButtonTooltip(this, recipe.getResultItem().getDisplayName()));
        button.setCurrentPage(0);
        recipeButtons.add(button);
        addRenderableWidget(button);
    }
    maxPageInclusive = (recipes.size() - 1) % recipesPerPage;
    addRenderableWidget(leftButton = NextPageButton.left(guiLeft + 7, guiTop + 65, button -> {
        if (currentPage < maxPageInclusive) {
            currentPage++;
            updateCurrentPage();
        }
    }));
    addRenderableWidget(rightButton = NextPageButton.right(guiLeft + 7, guiTop + 154, button -> {
        if (currentPage > 0) {
            currentPage--;
            updateCurrentPage();
        }
    }));
    updateCurrentPage();
}
Also used : ResourceLocation(net.minecraft.resources.ResourceLocation) AnvilPlanContainer(net.dries007.tfc.common.container.AnvilPlanContainer) Component(net.minecraft.network.chat.Component) AnvilPlanSelectButton(net.dries007.tfc.client.screen.button.AnvilPlanSelectButton) AnvilRecipe(net.dries007.tfc.common.recipes.AnvilRecipe) Inventory(net.minecraft.world.entity.player.Inventory) NextPageButton(net.dries007.tfc.client.screen.button.NextPageButton) RenderHelpers(net.dries007.tfc.client.RenderHelpers) ArrayList(java.util.ArrayList) PoseStack(com.mojang.blaze3d.vertex.PoseStack) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) CapabilityItemHandler(net.minecraftforge.items.CapabilityItemHandler) ItemStack(net.minecraft.world.item.ItemStack) Helpers(net.dries007.tfc.util.Helpers) Button(net.minecraft.client.gui.components.Button) AnvilBlockEntity(net.dries007.tfc.common.blockentities.AnvilBlockEntity) AnvilPlanSelectButton(net.dries007.tfc.client.screen.button.AnvilPlanSelectButton) AnvilRecipe(net.dries007.tfc.common.recipes.AnvilRecipe) ItemStack(net.minecraft.world.item.ItemStack)

Example 3 with AnvilRecipe

use of net.dries007.tfc.common.recipes.AnvilRecipe in project TerraFirmaCraft by TerraFirmaCraft.

the class AnvilPlanButton method getRecipe.

@Nullable
private AnvilRecipe getRecipe() {
    final Level level = anvil.getLevel();
    final Forging forging = anvil.getMainInputForging();
    if (level != null && forging != null) {
        return forging.getRecipe(level);
    }
    return null;
}
Also used : Forging(net.dries007.tfc.common.capabilities.forge.Forging) Level(net.minecraft.world.level.Level) Nullable(org.jetbrains.annotations.Nullable)

Example 4 with AnvilRecipe

use of net.dries007.tfc.common.recipes.AnvilRecipe in project TerraFirmaCraft by TerraFirmaCraft.

the class AnvilPlanButton method renderButton.

@Override
public void renderButton(PoseStack poseStack, int mouseX, int mouseY, float partialTick) {
    RenderSystem.setShader(GameRenderer::getPositionTexShader);
    RenderSystem.setShaderTexture(0, AnvilScreen.BACKGROUND);
    RenderSystem.setShaderColor(1f, 1f, 1f, 1f);
    blit(poseStack, x, y, 218, 0, width, height, 256, 256);
    final AnvilRecipe recipe = getRecipe();
    if (recipe != null) {
        Minecraft.getInstance().getItemRenderer().renderAndDecorateItem(recipe.getResultItem(), x + 1, y + 1);
    } else {
        blit(poseStack, x + 1, y + 1, 236, 0, 16, 16, 256, 256);
    }
    if (isHoveredOrFocused()) {
        renderToolTip(poseStack, mouseX, mouseY);
    }
}
Also used : GameRenderer(net.minecraft.client.renderer.GameRenderer) AnvilRecipe(net.dries007.tfc.common.recipes.AnvilRecipe)

Aggregations

AnvilRecipe (net.dries007.tfc.common.recipes.AnvilRecipe)2 Nullable (org.jetbrains.annotations.Nullable)2 PoseStack (com.mojang.blaze3d.vertex.PoseStack)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 AnvilRecipe (net.dries007.tfc.api.recipes.anvil.AnvilRecipe)1 Metal (net.dries007.tfc.api.types.Metal)1 RenderHelpers (net.dries007.tfc.client.RenderHelpers)1 AnvilPlanSelectButton (net.dries007.tfc.client.screen.button.AnvilPlanSelectButton)1 NextPageButton (net.dries007.tfc.client.screen.button.NextPageButton)1 AnvilBlockEntity (net.dries007.tfc.common.blockentities.AnvilBlockEntity)1 Forging (net.dries007.tfc.common.capabilities.forge.Forging)1 AnvilPlanContainer (net.dries007.tfc.common.container.AnvilPlanContainer)1 ItemMetal (net.dries007.tfc.objects.items.metal.ItemMetal)1 Helpers (net.dries007.tfc.util.Helpers)1 Button (net.minecraft.client.gui.components.Button)1 GameRenderer (net.minecraft.client.renderer.GameRenderer)1 ItemStack (net.minecraft.item.ItemStack)1 Component (net.minecraft.network.chat.Component)1 ResourceLocation (net.minecraft.resources.ResourceLocation)1