package openblocks.common;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.event.entity.living.LivingDeathEvent;
import openblocks.OpenBlocks;
import openblocks.common.tileentity.TileEntityGrave;

public class PlayerDeathHandler {

	/**
	 * Switched this to the player death event, because the inventory is cleared
	 * out before the item drop event. Either would work, I guess, but this is a
	 * bit neater
	 * 
	 * ... I say neater...
	 * 
	 * @param event
	 */
	@ForgeSubscribe
	public void onPlayerDeath(LivingDeathEvent event) {
		if (event.entityLiving != null
				&& event.entityLiving instanceof EntityPlayer) {

			EntityPlayer player = (EntityPlayer)event.entityLiving;
			World world = player.worldObj;

			if (!world.isRemote) {
				int x = (int)player.posX;
				int y = (int)player.posY;
				int z = (int)player.posZ;
				boolean aboveIsAir = false;

				for (int checkY = y; checkY > 1; checkY--) {
					if (!world.isAirBlock(x, checkY, z) && aboveIsAir) {
						checkY++;
						world.setBlock(x, checkY, z, OpenBlocks.Config.blockGraveId, 0, 2);
						TileEntity tile = world.getBlockTileEntity(x, checkY, z);
						if (tile != null && tile instanceof TileEntityGrave) {
							TileEntityGrave grave = (TileEntityGrave)tile;
							grave.setUsername(player.username);
							grave.setLoot(player.inventory);
							player.inventory.clearInventory(-1, -1);
							break;
						}
					} else {
						aboveIsAir = true;
					}
				}
			}
		}
	}
}

@@ -1126,21 +1126,36 @@
  %7B%0A%09%09%09%09%09
-if (!
+boolean thisIsAir = 
 world.is
@@ -1176,16 +1176,37 @@
 eckY, z)
+;%0A%09%09%09%09%09if (!thisIsAir
  && abov
@@ -1648,16 +1648,30 @@
 %09%09%7D else
+ if(thisIsAir)
  %7B%0A%09%09%09%09%09

Tweak the grave spawn logic