package com.hea3ven.buildingbricks.compat.vanilla;

import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ItemModelMesher;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;

import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;

import com.hea3ven.buildingbricks.compat.vanilla.blocks.BlockGrassSlab;
import com.hea3ven.buildingbricks.core.config.Config;
import com.hea3ven.buildingbricks.core.items.ItemColoredWrapper;
import com.hea3ven.buildingbricks.core.lib.BlockDescription;
import com.hea3ven.buildingbricks.core.materials.Material;
import com.hea3ven.buildingbricks.core.materials.MaterialBlockType;
import com.hea3ven.buildingbricks.core.materials.MaterialRegistry;
import com.hea3ven.buildingbricks.core.materials.StructureMaterial;

@Mod(modid = ModBuildingBricksCompatVanilla.MODID, name = "Building Bricks Vanilla Compatibilty",
		version = ModBuildingBricksCompatVanilla.VERSION)
public class ModBuildingBricksCompatVanilla {
	public static final String MODID = "buildingbrickscompatvanilla";
	public static final String VERSION = "1.0.0";

	public static Block grassSlab;

	static {
	}

	@EventHandler
	public void preInit(FMLPreInitializationEvent event) {
		Material grassMat = new Material("grass");
		grassMat.setTexture("minecraft:blocks/grass_top", "minecraft:blocks/dirt",
				"minecraft:blocks/grass_side");
		grassMat.setTexture("overlay", "minecraft:blocks/grass_side_overlay");
		grassMat.setStructureMaterial(StructureMaterial.GRASS);

		grassSlab = new BlockGrassSlab(grassMat).setUnlocalizedName("grass_slab");
		GameRegistry.registerBlock(grassSlab, ItemColoredWrapper.class, "grass_slab");

		grassMat.addBlock(new BlockDescription(MaterialBlockType.FULL, Blocks.grass));
		grassMat.addBlock(MaterialBlockType.STAIRS);
		grassMat.addBlock(new BlockDescription(MaterialBlockType.SLAB, grassSlab));
		grassMat.addBlock(MaterialBlockType.VERTICAL_SLAB);
		grassMat.addBlock(MaterialBlockType.STEP);
		grassMat.addBlock(MaterialBlockType.CORNER);
		MaterialRegistry.registerMaterial(grassMat);
	}

	@EventHandler
	public void init(FMLInitializationEvent event) {
		if (Config.generateGrassSlabs)
			MinecraftForge.EVENT_BUS.register(new GrassSlabWorldGen());

		if (event.getSide() == Side.CLIENT) {
			ItemModelMesher modelMesher = Minecraft
					.getMinecraft()
					.getRenderItem()
					.getItemModelMesher();
			modelMesher.register(Item.getItemFromBlock(grassSlab), 0, new ModelResourceLocation(
					"buildingbrickscompatvanilla:grass_slab", "inventory"));
		}
	}

}

@@ -45,16 +45,40 @@
 nilla;%0A%0A
+import java.util.List;%0A%0A
 import n
@@ -103,16 +103,59 @@
 .Block;%0A
+import net.minecraft.block.BlockStoneSlab;%0A
 import n
@@ -340,16 +340,16 @@
 Blocks;%0A
-
 import n
@@ -371,16 +371,186 @@
 em.Item;
+%0Aimport net.minecraft.item.ItemBlock;%0Aimport net.minecraft.item.ItemStack;%0Aimport net.minecraft.item.crafting.CraftingManager;%0Aimport net.minecraft.item.crafting.IRecipe;
 %0A%0Aimport
@@ -2892,16 +2892,45 @@
 en());%0A%0A
+%09%09replaceStoneSlabRecipe();%0A%0A
 %09%09if (ev
@@ -3233,10 +3233,782 @@
 %09%09%7D%0A%09%7D%0A%0A
+%09private void replaceStoneSlabRecipe() %7B%0A%09%09List%3CIRecipe%3E recipes = CraftingManager.getInstance().getRecipeList();%0A%09%09for (int i = 0; i %3C recipes.size(); i++) %7B%0A%09%09%09IRecipe recipe = recipes.get(i);%0A%09%09%09ItemStack result = recipe.getRecipeOutput();%0A%09%09%09if (result != null && result.getItem() instanceof ItemBlock%0A%09%09%09%09%09&& ((ItemBlock) result.getItem()).getBlock() == Blocks.stone_slab%0A%09%09%09%09%09&& result.getMetadata() == BlockStoneSlab.EnumType.STONE.getMetadata()) %7B%0A%09%09%09%09recipes.remove(i);%0A%09%09%09%7D%0A%09%09%7D%0A%0A%09%09ItemStack stoneSlab = new ItemStack(Block.getBlockFromName(%22buildingbricks:stone_slab%22));%0A%09%09ItemStack stoneSlabSlab = new ItemStack(Blocks.stone_slab, 2,%0A%09%09%09%09BlockStoneSlab.EnumType.STONE.getMetadata());%0A%09%09GameRegistry.addShapedRecipe(stoneSlabSlab, %22x%22, %22x%22, 'x', stoneSlab);%0A%09%7D%0A%0A
 %7D%0A

Replace stone slabs recipe