package totemic_commons.pokefenn.block.tipi;

import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import totemic_commons.pokefenn.ModBlocks;
import totemic_commons.pokefenn.lib.Strings;

/**
 * Created by Pokefenn.
 * Licensed under MIT (If this is one of my Mods)
 */
public class BlockDummyTipi extends Block
{
    public BlockDummyTipi()
    {
        super(Material.CLOTH);
        setRegistryName(Strings.DUMMY_TIPI_NAME);
        setUnlocalizedName(Strings.DUMMY_TIPI_NAME);
        setHardness(0.2F);
        setSoundType(SoundType.CLOTH);
    }

    @Override
    public void onBlockHarvested(World world, BlockPos pos, IBlockState state, EntityPlayer player)
    {
        //find main Tipi block
        int range = 1;
        int height = 5;
        for(int i = -range; i <= range; i++)
            for(int j = 0; j >= -height; j--) //search downwards
                for(int k = -range; k <= range; k++)
                {
                    BlockPos p = pos.add(i, j, k);
                    IBlockState s = world.getBlockState(p);
                    if(s.getBlock() == ModBlocks.tipi)
                    {
                        BlockDummyTipi.breakTipi(world, p);
                        return;
                    }
                }
    }

    public static void breakTipi(World world, BlockPos pos)
    {
        int height = 5;
        int radius = 2;
        for(int i = -radius; i <= radius; i++)
            for(int j = 0; j <= height; j++)
                for(int k = -radius; k <= radius; k++)
                {
                    BlockPos p = pos.add(i, j, k);
                    IBlockState s = world.getBlockState(p);

                    if(s.getBlock() == ModBlocks.dummyTipi)
                    {
                        world.setBlockToAir(p);
                    }
                    else if(s.getBlock() == ModBlocks.tipi)
                    {
                        s.getBlock().dropBlockAsItem(world, p, world.getBlockState(p), 0);
                        world.setBlockToAir(p);
                    }
                }
    }

    @Override
    public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player)
    {
        return new ItemStack(ModBlocks.tipi);
    }

    @Override
    public EnumBlockRenderType getRenderType(IBlockState state)
    {
        return EnumBlockRenderType.INVISIBLE;
    }

    @Override
    public int quantityDropped(Random random)
    {
        return 0;
    }

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

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

@@ -133,24 +133,78 @@
 .SoundType;%0A
+import net.minecraft.block.material.EnumPushReaction;%0A
 import net.m
@@ -2837,32 +2837,161 @@
 VISIBLE;%0A    %7D%0A%0A
+    @Override%0A    public EnumPushReaction getMobilityFlag(IBlockState state)%0A    %7B%0A        return EnumPushReaction.BLOCK;%0A    %7D%0A%0A
     @Override%0A  

Make Tipi blocks unable to be moved my pistons