package com.corwinjv.mobtotems.blocks;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import javax.annotation.Nonnull;

/**
 * Created by CorwinJV on 7/13/2016.
 */
public class SacredLightBlock extends ModBlock
{
    public SacredLightBlock()
    {
        super(Material.CIRCUITS);
    }

    // Rendering stuff
    public boolean isVisuallyOpaque()
    {
        return false;
    }

    public boolean doesSideBlockRendering(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing face)
    {
        return false;
    }

    @Nonnull
    @SideOnly(Side.CLIENT)
    public BlockRenderLayer getBlockLayer()
    {
        return BlockRenderLayer.CUTOUT;
    }

    // Can only place on the tops of solid things
    private boolean canPlaceOn(World worldIn, BlockPos pos)
    {
        IBlockState state = worldIn.getBlockState(pos);
        if (state.isSideSolid(worldIn, pos, EnumFacing.UP))
        {
            return true;
        }
        else
        {
            return state.getBlock().canPlaceTorchOnTop(state, worldIn, pos);
        }
    }

    @Override
    public boolean canPlaceBlockAt(World worldIn, @Nonnull BlockPos pos)
    {
        return this.canPlaceAt(worldIn, pos, EnumFacing.UP);
    }

    private boolean canPlaceAt(World worldIn, BlockPos pos, EnumFacing facing)
    {
        BlockPos blockpos = pos.offset(facing.getOpposite());
        return this.canPlaceOn(worldIn, blockpos);
    }

    // Will pop off if it is no longer on the top of a solid thing
    public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
    {
        this.checkForDrop(worldIn, pos, state);
    }

    // neighborChanged is deprecated and I have no idea what I'm supposed to use instead
    public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn)
    {
        this.checkForDrop(worldIn, pos, state);
    }

    protected boolean checkForDrop(World worldIn, BlockPos pos, IBlockState state)
    {
        if (this.canPlaceAt(worldIn, pos, EnumFacing.UP))
        {
            return true;
        }
        else
        {
            if (worldIn.getBlockState(pos).getBlock() == this)
            {
                this.dropBlockAsItem(worldIn, pos, state, 0);
                worldIn.setBlockToAir(pos);
            }

            return false;
        }
    }
}

@@ -357,16 +357,61 @@
 .World;%0A
+import net.minecraftforge.fml.common.FMLLog;%0A
 import n
@@ -499,16 +499,55 @@
 ideOnly;
+%0Aimport org.apache.logging.log4j.Level;
 %0A%0Aimport
@@ -2096,16 +2096,36 @@
 %0A%0A    //
+ Okay, so I see that
  neighbo
@@ -2151,59 +2151,173 @@
 ted 
-and I have no idea what I'm supposed to use instead
+but it appears that onNeighborChange(IBlockAccess, BlockPos, BlockPos)%0A    // doesn't get called when a sand block is broken under the SacredLightBlock%0A    @Override
 %0A   
@@ -2458,31 +2458,135 @@
 os, state);%0A
-
     %7D%0A%0A
+    @Override%0A    public void onNeighborChange(IBlockAccess world, BlockPos pos, BlockPos neighbor) %7B%7D%0A%0A
     protecte

Add onNeighborChange to use in place of neighborChanged down the road.