package com.zivilon.cinder_loe.blocks;

import lotr.common.LOTRCreativeTabs;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.world.World;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

import java.lang.reflect.Field;

public class CinderBlock extends Block {

    public CinderBlock() {
        super(Material.rock);
        try {
            Field tabField = LOTRCreativeTabs.class.getDeclaredField("tabBlock"); // Stupid workaround because ForgeGradle tries to obfuscate field LOTRCreativeTabs.tabBlock when it's not supposed to
            LOTRCreativeTabs tab = (LOTRCreativeTabs)tabField.get(null);
            setCreativeTab((CreativeTabs)tab);
        } catch (NoSuchFieldException | IllegalAccessException e) {
            e.printStackTrace();
        }
        setHardness(2.0F);
        setResistance(5.0F);
        setBlockTextureName("lotr:cinder_block");
        setBlockName("lotr:cinderBlock");
        setLightLevel(0.25F);
    }

    @SideOnly(Side.CLIENT)
    public void registerBlockIcons(IIconRegister iconRegister) {
        this.blockIcon = iconRegister.registerIcon("lotr:cinder_block");
    }

    @Override
    public void onEntityWalking(World world, int x, int y, int z, Entity entity) {
        entity.setFire(20);
    }
}
