package com.techern.minecraft.pathomania.blocks;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;

/**
 * BlockPath; A class used to create path {@link net.minecraft.block.Block}s
 *
 * @since 0.0.1
 */
public class BlockPath extends Block {

    /**
     * The dirt {@link BlockPath} instance
     *
     * @since 0.0.1
     */
    public static BlockPath DIRT_PATH = new BlockPath("blockDirtPath", Material.ground, Blocks.dirt);

    /**
     * The grass {@link BlockPath} instance
     *
     * @since 0.0.1
     */
    public static BlockPath GRASS_PATH = new BlockPath("blockGrassPath", Material.ground, Blocks.grass);

    /**
     * The {@link Block} to use as a fallback
     *
     * @since 0.0.1
     */
    private Block fallbackBlock;

    /**
     * Gets this {@link BlockPath}'s fallback {@link Block}
     *
     * @return The fallback {@link Block}
     * @since 0.0.1
     */
    public Block getFallbackBlock() {
        return this.fallbackBlock;
    }

    /**
     * Creates a new {@link BlockPath}
     *
     * @param name The name of this {@link BlockPath}
     * @param material The {@link Material} used for this {@link BlockPath}
     * @param fallbackBlock The {@link Block} used as a fallback
     *
     * @since 0.0.1
     */
    public BlockPath(String name, Material material, Block fallbackBlock) {
        super(material);
        this.setUnlocalizedName(name);

        this.setStepSound(fallbackBlock.stepSound);

        this.fallbackBlock = fallbackBlock;

        this.setCreativeTab(CreativeTabs.tabBlock); //TODO: Creative tab for pathways
        this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.9375F, 1.0F);

    }

    @Override
    public boolean isFullCube() {
        return false;
    }

    @Override
    public boolean isOpaqueCube() {
        return false;
    }

    /**
     * Called when a neighboring block changes.
     *
     * @param worldIn The {@link World} the change happened in
     * @param pos The current {@link BlockPos} of this {@link BlockPath}
     * @param state The current {@link IBlockState} of the (current?) block
     * @param neighborBlock The neighboring {@link Block}
     *
     * @since 0.0.1
     */
    @Override
    public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock) {
        super.onNeighborBlockChange(worldIn, pos, state, neighborBlock);

        if (worldIn.getBlockState(pos.up()).getBlock().getMaterial().isSolid())
        {
            worldIn.setBlockState(pos, this.getFallbackBlock().getDefaultState());
        }
    }

}

@@ -43,16 +43,137 @@
 locks;%0A%0A
+import com.techern.minecraft.pathomania.PathomaniaMod;%0Aimport com.techern.minecraft.pathomania.util.ReflectionUtilities;%0A
 import n
@@ -442,16 +442,49 @@
 World;%0A%0A
+import java.lang.reflect.Field;%0A%0A
 /**%0A * B
@@ -1823,24 +1823,882 @@
 tepSound);%0A%0A
+        //Time for reflection-only use cases%0A        try %7B%0A            Class%3C? extends Block%3E blockClass = fallbackBlock.getClass();%0A%0A            Field hardnessField = ReflectionUtilities.getFieldInHierarchy(blockClass, %22blockHardness%22);%0A            hardnessField.setAccessible(true);%0A%0A            this.setHardness(hardnessField.getFloat(fallbackBlock));%0A%0A            Field resistanceField = ReflectionUtilities.getFieldInHierarchy(blockClass, %22blockResistance%22);%0A            resistanceField.setAccessible(true);%0A%0A            this.setResistance(resistanceField.getFloat(fallbackBlock));%0A%0A        %7D catch (NoSuchFieldException %7C IllegalAccessException e) %7B%0A            PathomaniaMod.LOGGER.error(%22Exception while automatically setting path data. It should partially work, though. Contact me, please :(%22);%0A            PathomaniaMod.LOGGER.error(e);%0A        %7D%0A%0A
         this

Use reflection to set the hardness and resistance of a block