Skip to content

Instantly share code, notes, and snippets.

@Dockter
Created March 28, 2020 17:07
Show Gist options
  • Save Dockter/d515f07fe85a3f24782df3e065248083 to your computer and use it in GitHub Desktop.
Save Dockter/d515f07fe85a3f24782df3e065248083 to your computer and use it in GitHub Desktop.
public boolean canBlockStay(World worldIn, BlockPos pos)
{
for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
{
Material material = worldIn.getBlockState(pos.offset(enumfacing)).getMaterial();
if (material.isSolid() || material == Material.LAVA)
{
return false;
}
}
Block block = worldIn.getBlockState(pos.down()).getBlock();
return block == Blocks.CACTUS || block == Blocks.SAND && !worldIn.getBlockState(pos.up()).getMaterial().isLiquid();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment