package com.blamejared.compat.betterwithmods;

import betterwithmods.common.registry.block.recipe.BlockIngredient;
import betterwithmods.common.registry.heat.BWMHeatRegistry;
import com.blamejared.mtlib.helpers.InputHelper;
import com.blamejared.mtlib.helpers.LogHelper;
import com.blamejared.mtlib.utils.BaseAction;
import crafttweaker.CraftTweakerAPI;
import crafttweaker.annotations.ModOnly;
import crafttweaker.annotations.ZenRegister;
import crafttweaker.api.item.IItemStack;
import crafttweaker.api.minecraft.CraftTweakerMC;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;

@ZenClass("mods.betterwithmods.HeatRegistry")
@ModOnly("betterwithmods")
@ZenRegister
public class HeatRegistry {

    @ZenMethod
    public static void addHeatSource(crafttweaker.api.block.IBlockState state, int heat) {
        CraftTweakerAPI.apply(new AddHeatSource(CraftTweakerMC.getBlockState(state), heat));
    }

    @SuppressWarnings("deprecation")
    @ZenMethod
    public static void addHeatSource(IItemStack stack, int heat) {
        if (InputHelper.isABlock(stack)) {
            Block block = CraftTweakerMC.getBlock(stack);
            IBlockState state = block.getStateFromMeta(stack.getMetadata());
            CraftTweakerAPI.apply(new AddHeatSource(state, heat));
        } else {
            LogHelper.logError(String.format("%s input must create a valid BlockState", stack.getDisplayName()), new IllegalArgumentException(String.format("%s input must create a valid BlockState", stack.getDisplayName())));
        }
    }

    public static class AddHeatSource extends BaseAction {

        private IBlockState state;
        private int heat;

        AddHeatSource(IBlockState state, int heat) {
            super("Add Heat");
            this.state = state;
            this.heat = heat;
        }

        @Override
        public void apply() {
            BWMHeatRegistry.addHeatSource(new BlockIngredient(new ItemStack(state.getBlock())), heat);
        }
    }
}

@@ -91,21 +91,21 @@
 .recipe.
-Block
+State
 Ingredie
@@ -524,16 +524,101 @@
 akerMC;%0A
+import java.util.Arrays;%0Aimport java.util.List;%0Aimport java.util.stream.Collectors; %0A
 import n
@@ -1097,16 +1097,30 @@
 tSource(
+Arrays.asList(
 CraftTwe
@@ -1146,16 +1146,303 @@
 e(state)
+), heat));%0A    %7D%0A    %0A    @ZenMethod%0A    public static void addHeatSource(List%3Ccrafttweaker.api.block.IBlockState%3E states, IItemStack displayStack, int heat) %7B%0A        CraftTweakerAPI.apply(new AddHeatSource(states.stream().map(CraftTweakerMC::getBlockState).collect(Collectors.toList())
 , heat))
@@ -1799,21 +1799,36 @@
 tSource(
+Arrays.asList(
 state
+)
 , heat))
@@ -2165,16 +2165,21 @@
 private 
+List%3C
 IBlockSt
@@ -2181,22 +2181,64 @@
 ockState
+%3E
  state
+s;%0A        private ItemStack displayStack
 ;%0A      
@@ -2280,16 +2280,21 @@
 tSource(
+List%3C
 IBlockSt
@@ -2288,38 +2288,64 @@
 List%3CIBlockState
+%3E
  state
+s, ItemStack displayStack
 , int heat) %7B%0A  
@@ -2399,16 +2399,17 @@
 tate
+s
  = state
 ;%0A  
@@ -2408,38 +2408,237 @@
 tate
-;%0A            this.heat = heat
+s;%0A            this.displayStack = displayStack;%0A            this.heat = heat;%0A        %7D%0A        %0A        AddHeatSource(List%3CIBlockState%3E states, int heat) %7B%0A            this(states, new ItemStack(states.get(0).getBlock()), heat)
 ;%0A  
@@ -2740,21 +2740,21 @@
 rce(new 
-Block
+State
 Ingredie
@@ -2760,38 +2760,42 @@
 ent(
-new ItemStack(state.getBlock()
+states, Arrays.asList(displayStack
 )), 

Fix blockstates with BWM HeatRegistry (#766)